Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.419
diff -u -p -r1.419 taxonomy.module
--- modules/taxonomy/taxonomy.module	23 Apr 2008 20:01:54 -0000	1.419
+++ modules/taxonomy/taxonomy.module	26 Apr 2008 18:15:07 -0000
@@ -819,9 +819,9 @@ function taxonomy_get_children($tid, $vi
  *   The number of levels of the tree to return. Leave NULL to return all levels.
  *
  * @return
- *   An array of all term objects in the tree. Each term object is extended
- *   to have "depth" and "parents" attributes in addition to its normal ones.
- *   Results are statically cached.
+ *   An array of all term objects in the tree, indexed by taxonomy id (tid).
+ *   Each term object is extended to have "depth" and "parents" attributes in
+ *   addition to its normal ones.  Results are statically cached.
  */
 function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
   static $children, $parents, $terms;
@@ -851,10 +851,9 @@ function taxonomy_get_tree($vid, $parent
         // The "parent" attribute is not useful, as it would show one parent only.
         unset($term->parent);
         $term->parents = $parents[$vid][$child];
-        $tree[] = $term;
-
+        $tree[$term->tid] = $term;
         if (!empty($children[$vid][$child])) {
-          $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
+          $tree += taxonomy_get_tree($vid, $child, $depth, $max_depth);
         }
       }
     }
