Index: admin_menu.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.inc,v
retrieving revision 1.56
diff -u -p -r1.56 admin_menu.inc
--- admin_menu.inc	23 Jul 2009 22:30:53 -0000	1.56
+++ admin_menu.inc	24 Jul 2009 08:45:35 -0000
@@ -200,6 +200,8 @@ function admin_menu_links_user() {
         ),
       );
     }
+    // Add switch user form.
+    $links['account']['form'] = drupal_get_form('devel_switch_user_form');
   }
 
   return $links;
Index: admin_menu.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v
retrieving revision 1.89
diff -u -p -r1.89 admin_menu.module
--- admin_menu.module	23 Jul 2009 22:30:53 -0000	1.89
+++ admin_menu.module	24 Jul 2009 09:00:35 -0000
@@ -477,6 +477,7 @@ function theme_admin_menu_links(&$elemen
   }
 
   $output = '';
+  $depth_child = $depth + 1;
   foreach (element_children($elements, TRUE) as $path) {
     // Early-return nothing if user does not have access.
     if (isset($elements[$path]['#access']) && !$elements[$path]['#access']) {
@@ -487,18 +488,21 @@ function theme_admin_menu_links(&$elemen
       '#options' => array(),
     );
     // Render children to determine whether this link is expandable.
-    $children = theme('admin_menu_links', $elements[$path], $depth + 1);
-    if (!empty($children)) {
-      $elements[$path]['#attributes']['class'][] = 'expandable';
-      // If there are children, we add the parent key as class by default.
-      // $elements[$path]['#attributes']['class'][] = $path;
+    if (isset($elements[$path]['#type']) || isset($elements[$path]['#theme'])) {
+      $elements[$path]['#admin_menu_depth'] = $depth_child;
+      $elements[$path]['#children'] = drupal_render($elements[$path]);
     }
-    if (isset($elements[$path]['#attributes']['class'])) {
-      $elements[$path]['#attributes']['class'] = implode(' ', $elements[$path]['#attributes']['class']);
+    else {
+      $elements[$path]['#children'] = theme('admin_menu_links', $elements[$path], $depth_child);
+      if (!empty($elements[$path]['#children'])) {
+        $elements[$path]['#attributes']['class'][] = 'expandable';
+      }
+      if (isset($elements[$path]['#attributes']['class'])) {
+        $elements[$path]['#attributes']['class'] = implode(' ', $elements[$path]['#attributes']['class']);
+      }
     }
 
-    $output .= '<li' . drupal_attributes($elements[$path]['#attributes']) . '>';
-
+    $link = '';
     if (isset($elements[$path]['#href'])) {
       // Strip destination query string from href attribute and apply a CSS class
       // for our JavaScript behavior instead.
@@ -523,7 +527,7 @@ function theme_admin_menu_links(&$elemen
         $elements[$path]['#options']['attributes']['class'] .= ' admin-menu-destination';
       }
 
-      $output .= l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
+      $link .= l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
     }
     elseif (isset($elements[$path]['#title'])) {
       if (!empty($elements[$path]['#options']['html'])) {
@@ -533,22 +537,21 @@ function theme_admin_menu_links(&$elemen
         $title = check_plain($elements[$path]['#title']);
       }
       if (!empty($elements[$path]['#options']['attributes'])) {
-        $output .= '<span' . drupal_attributes($elements[$path]['#options']['attributes']) . '>' . $title . '</span>';
+        $link .= '<span' . drupal_attributes($elements[$path]['#options']['attributes']) . '>' . $title . '</span>';
       }
       else {
-        $output .= $title;
+        $link .= $title;
       }
     }
 
-    $output .= $children;
+    $output .= '<li' . drupal_attributes($elements[$path]['#attributes']) . '>';
+    $output .= $link . $elements[$path]['#children'];
     $output .= '</li>';
   }
   // @todo #attributes probably required for UL, but already used for LI.
-  // @todo Use $element['#theme'] + $element['#children'] here instead.
-  if ($output) {
-    if ($depth > 0) {
-      $output = "\n<ul>" . $output . '</ul>';
-    }
+  // @todo Use $element['#children'] here instead.
+  if ($output && $depth_child > 0) {
+    $output = "\n<ul>" . $output . '</ul>';
   }
   return $output;
 }
