diff --git a/nodehierarchy.module b/nodehierarchy.module
index 9dd6800..c2cf590 100644
--- a/nodehierarchy.module
+++ b/nodehierarchy.module
@@ -1666,10 +1666,17 @@ function _nodehierarchy_tree_data($result, $exclude = NULL, $allowed_types, $dep
   $remnant = NULL;
   $tree = array();
   $enabled_tree = TRUE;
-  $exclude = NULL;
+  $excluded_nids = array();
+  if($exclude) {
+    $excluded_nids[] = $exclude;
+  }
 
   foreach ($result as $item) {
-    if ($exclude !== $item['nid']) {
+    $item_parents = array_filter(nodehierarchy_get_node_parent_nids($item['nid'])); 
+    if(array_intersect($item_parents, $excluded_nids)) {
+      $excluded_nids[] = $item['nid'];
+    }
+    if (!in_array($item['nid'], $excluded_nids)) {
       $item['disabled'] = in_array($item['type'], $allowed_types) ? FALSE : TRUE;
 //      $item['disabled'] = $item['disabled'] || (!node_access('update', $item) && !user_access('create child of any parent'));
       $enabled_tree = $enabled_tree || empty($item['disabled']) || (isset($previous_element['disabled']) && empty($previous_element['disabled']));
