Returns a nested array containing only the leaf concepts, at their actual depths in the tree of nodes.
485512
function getNestedNodes(concept, condition) {
  if (condition(concept)) {
    return concept;
  }
  if (!concept.items) {
    return [];
  }
  return concept.items.map(child => getNestedNodes(child, condition));
}
412517
private IConceptSet getLeaves(final IConceptSet concepts) {
        // Deal with any equivalent concepts. If there are equivalent concepts in the set then we only keep one of them.
        // Otherwise, both will get eliminated from the final set.
        final IConceptSet filtered = filterEquivalents(concepts);

        final IConceptSet leafBs = IConceptSet.FACTORY.createConceptSet(filtered);
        final IConceptSet set = IConceptSet.FACTORY.createConceptSet(leafBs);

        for (final IntIterator bItr = set.iterator(); bItr.hasNext(); ) {
            final int b = bItr.next();

            final IConceptSet ancestors = IConceptSet.FACTORY.createConceptSet(getAncestors(no, b));
            ancestors.remove(b);
            leafBs.removeAll(ancestors);
        }
        return leafBs;
    }
1289384
public IntList getRoots() {
    IntList roots = new IntArrayList();
    for(int i = 0; i < used; i++) {
      // roots or one element in component
      if(parent[i] == i) {
        roots.add(i);
      }
    }
    return roots;
  }
217048
private int depth() {
        int i = 0;
        for (TreeString p = this; p != null; p = p.parent) {
            i++;
        }
        return i;
    }
87000
def get_leaf(self, index):
        
        leaf_level_index = len(self.tree['levels']) - 1
        if index < 0 or index > len(self.tree['levels'][leaf_level_index]) - 1:
            # index is out of bounds
            return None
        return self.tree['levels'][leaf_level_index][index]
673264
def _treeify(values):
        """"""
        if len(values) == 1:  # this case causes problems later
            return values
        tree = np.empty_like(values)
        # Tree indices work as follows:
        # 0 is the root
        # 2n+1 is the left child of n
        # 2n+2 is the right child of n
        # So we now rearrange `values` into that format...

        # The first step is to remove the bottom row of leaves, which might not be exactly full
        last_full_row = int(np.log2(len(values) + 1) - 1)
        len_ragged_row = len(values) - (2 ** (last_full_row + 1) - 1)
        if len_ragged_row > 0:
            bottom_row_ix = np.s_[: 2 * len_ragged_row : 2]
            tree[-len_ragged_row:] = values[bottom_row_ix]
            values = np.delete(values, bottom_row_ix)

        # Now `values` is length 2**n - 1, so can be packed efficiently into a tree
        # Last row of nodes is indices 0, 2, ..., 2**n - 2
        # Second-last row is indices 1, 5, ..., 2**n - 3
        # nth-last row is indices (2**n - 1)::(2**(n+1))
        values_start = 0
        values_space = 2
        values_len = 2 ** last_full_row
        while values_start < len(values):
            tree[values_len - 1 : 2 * values_len - 1] = values[values_start::values_space]
            values_start += int(values_space / 2)
            values_space *= 2
            values_len = int(values_len / 2)
        return tree
1307686
def get_treenodes(self):
        ""

        if not self.multitree:
            # get TreeNodes from Newick
            extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt)
        
            # extract one tree
            self.treenodes.append(extractor.newick_from_string())

        else:
            for tre in self.data:
                # get TreeNodes from Newick
                extractor = Newick2TreeNode(tre.strip(), fmt=self.fmt)
        
                # extract one tree
                self.treenodes.append(extractor.newick_from_string())
798485
def get_tree(cls, parent=None):
        
        cls = get_result_class(cls)

        if parent is None:
            # return the entire tree
            return cls.objects.all()
        if parent.is_leaf():
            return cls.objects.filter(pk=parent.pk)
        return cls.objects.filter(
            path__startswith=parent.path,
            depth__gte=parent.depth
        ).order_by(
            'path'
        )
1011479
public ArrayList getTreePerfLevelDescriptors(int parentLevel) {
        ArrayList res = new ArrayList();
        int thisLevel = level;
        if (instance == null) { // should be root
            res.add(new PerfLevelDescriptor(new String[] { "pmi" }, thisLevel));
        } else {
            PmiModule instance = getInstance();
            thisLevel = instance.getInstrumentationLevel();
            // if the level is same as parent, do not add to the list
            if ((thisLevel != LEVEL_UNDEFINED) && (thisLevel != parentLevel)) {
                res.add(new PerfLevelDescriptor(instance.getPath(), thisLevel, instance.getModuleID()));
            }
        }

        // get from children
        ModuleItem[] items = children();
        if (items == null)
            return res;
        for (int i = 0; i < items.length; i++) {
            ArrayList childrenLevels = items[i].getTreePerfLevelDescriptors(thisLevel);
            for (int j = 0; j < childrenLevels.size(); j++)
                res.add(childrenLevels.get(j));
        }
        return res;
    }
1009053
private function createTreeArray()
    {
        $tree = [];

        foreach($this->models as $model) {
            $tree[] = [
                'id' => $model->{$this->id},
                'parent_id' => $model->{$this->parent_id},
                'model' => $model,
            ];
        }

        return $tree;
    }
774683
def get_all_rooted_subtrees_as_lists(self, start_location=None):
        """"""
        if start_location is not None and start_location not in self._location_to_children:
            raise AssertionError(u'Received invalid start_location {} that was not present '
                                 u'in the tree. Present root locations of complex @optional '
                                 u'queries (ones that expand vertex fields within) are: {}'
                                 .format(start_location, self._location_to_children.keys()))

        if start_location is None:
            start_location = self._root_location

        if len(self._location_to_children[start_location]) == 0:
            # Node with no children only returns a singleton list containing the null set.
            return [[]]

        current_children = sorted(self._location_to_children[start_location])

        # Recursively find all rooted subtrees of each of the children of the current node.
        location_to_list_of_subtrees = {
            location: list(self.get_all_rooted_subtrees_as_lists(location))
            for location in current_children
        }

        # All subsets of direct child Location objects
        all_location_subsets = [
            list(subset)
            for subset in itertools.chain(*[
                itertools.combinations(current_children, x)
                for x in range(0, len(current_children) + 1)
            ])
        ]

        # For every possible subset of the children, and every combination of the chosen
        # subtrees within, create a list of subtree Location lists.
        new_subtrees_as_lists = []
        for location_subset in all_location_subsets:
            all_child_subtree_possibilities = [
                location_to_list_of_subtrees[location]
                for location in location_subset
            ]
            all_child_subtree_combinations = itertools.product(*all_child_subtree_possibilities)

            for child_subtree_combination in all_child_subtree_combinations:
                merged_child_subtree_combination = list(itertools.chain(*child_subtree_combination))
                new_subtree_as_list = location_subset + merged_child_subtree_combination
                new_subtrees_as_lists.append(new_subtree_as_list)

        return new_subtrees_as_lists
1370855
function(nodes) {
        var ans = [], config = this.config, root = this.viz.root;
        nodes.sort(function(a, b) { return (a._depth <= b._depth) - (a._depth >= b._depth); });
        for(var i=0; i<nodes.length; i++) {
            if(nodes[i].anySubnode("exist")) {
            	for (var j = i+1, desc = false; !desc && j < nodes.length; j++) {
                    if(!config.multitree || '$orn' in nodes[j].data) {
                		desc = desc || nodes[i].isDescendantOf(nodes[j].id);                    	
                    }
                }
                if(!desc) ans.push(nodes[i]);
            }
        }
        return ans;
    }
233803
public function getRootNodes()
	{
		$searchCondition = $this->createSearchCondition();
		$searchCondition->levelEqualsTo(0);

		$rootNodes = $this->search($searchCondition);
		return $rootNodes;
	}
561240
def deep_nodes(self, allnodes=None):
        
        allnodes = (allnodes or [])
        for (node, node_) in ((node, node_) for (node, node_) in\
            self.iteritems() if not node in allnodes):
            allnodes.append(node)
            node_.deep_nodes(allnodes)
        return allnodes
665782
def get_nodes(self):
        
        return self.fold_up(lambda n, fl, fg: [n] + fl + fg, lambda leaf: [leaf])
1278621
def leaf_list(cls, name, parent=None, interleave=None):
        """"""
        node = cls("_list_", parent, interleave=interleave)
        node.attr["name"] = name
        node.keys = None
        node.minEl = "0"
        node.maxEl = None
        node.occur = 3
        return node
125455
def get_leaves(self):
        """"""
        ret_set = set()
        for val in self.values():
            if isinstance(val, self.__class__):
                ret_set |= val.get_leaves()
            elif isinstance(val, dict):
                ret_set |= set(val.values())
            elif isinstance(val, list):
                ret_set |= set(val)
            elif isinstance(val, set):
                ret_set |= val
            else:
                ret_set.add(val)
        return ret_set