--- menu.inc	Fri Sep  9 12:21:11 2011
+++ menu_new.inc	Fri Sep  9 13:45:09 2011
@@ -896,7 +896,31 @@ function menu_tree_page_data($menu_name 
             $args[] = '<front>';
             $placeholders .= ", '%s'";
           }
-          $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (". $placeholders .")", $args));
+          // In the case where there is more than one match on a link
+          // path, give precedence to lowest depth (limit 1), then find other 
+          // matches in the same branch. This approach prevents two branches 
+          // from being active simultaneously and addresses a common use case 
+          // where both the parent and first child of a menu branch point to 
+          // the same location. 
+          $parents = array();
+          $args = array_merge($args, $args);
+          $result = db_query("
+            SELECT m1.p1, m1.p2, m1.p3, m1.p4, m1.p5, m1.p6, m1.p7, m1.p8 
+            FROM {menu_links} m1 WHERE 
+            (
+            SELECT m2.mlid 
+            FROM {menu_links} m2 
+            WHERE m2.menu_name = '%s' 
+            AND m2.link_path IN (". $placeholders .")
+            ORDER BY m2.depth LIMIT 1
+            ) 
+            IN (m1.p1, m1.p2, m1.p3, m1.p4, m1.p5, m1.p6, m1.p7, m1.p8) 
+            AND m1.menu_name = '%s' 
+            AND m1.link_path 
+            IN (". $placeholders .")", $args);
+          while ($row = db_fetch_array($result)) {
+            $parents = array_merge($parents, array_values($row));
+          }
 
           if (empty($parents)) {
             // If no link exists, we may be on a local task that's not in the links.
