--- uc_catalog.module.original	2011-03-08 18:57:03.000000000 -0600
+++ uc_catalog.module	2011-03-08 18:51:44.000000000 -0600
@@ -598,29 +598,9 @@ function _uc_catalog_block_summarize($fo
 function _uc_catalog_navigation($branch) {
   static $terms;
   static $breadcrumb;
-  static $types;
-  
-  if (empty($types)) {
-    $types = uc_product_types();
-  }
 
-
-  // get current node count 
-  $query = new EntityFieldQuery();
-  $query->entityCondition('entity_type', 'node')
-    ->entityCondition('bundle', $types)
-    ->fieldCondition('taxonomy_catalog', 'tid', $branch->tid)
-    ->count();
-  $num = $query->execute();
-  //get counts of all children
- foreach ($branch->children as $child) {
-  $query = new EntityFieldQuery();
-  $query->entityCondition('entity_type', 'node')
-    ->entityCondition('bundle', $types)
-    ->fieldCondition('taxonomy_catalog', 'tid', $child->tid)
-    ->count();
-  $num += $query->execute();
-  }
+  //traverse tree and find sum
+  $num = _uc_catalog_navigation_traverse($branch);
 
   // No nodes in category or descendants. Not in path and display nothing.
   if (!$num) {
@@ -694,6 +674,30 @@ function _uc_catalog_navigation($branch)
   return array($inpath, $output);
 }
 
+function _uc_catalog_navigation_traverse ($branch) {
+  static $types;
+  
+  if (empty($types)) {
+    $types = uc_product_types();
+  }
+
+  // get current node count 
+  $query = new EntityFieldQuery();
+  $query->entityCondition('entity_type', 'node')
+    ->entityCondition('bundle', $types)
+    ->fieldCondition('taxonomy_catalog', 'tid', $branch->tid)
+    ->count();
+  $num = $query->execute();
+  //get counts of all children
+ foreach ($branch->children as $child) {
+       $num += _uc_catalog_navigation_traverse($child);
+ }
+  
+  return $num;
+}
+
+
+
 /**
  * Displays a formatted link in the catalog block.
  *
