Return a list of all leaves (nodes with no downstreams)
162217
def all_leaves(self, graph=None):
        
        if graph is None:
            graph = self.graph
        return [key for key in graph if not graph[key]]
852936
def get_descendants(self, strategy="levelorder", is_leaf_fn=None):
        
        return [n for n in self.iter_descendants(
            strategy=strategy, is_leaf_fn=is_leaf_fn)]
111506
def get_nodes(self):
        

        return [node for node in foundations.walkers.nodes_walker(self.model().root_node)]
656892
def _get_tree_properties(root):
    
    is_descending = True
    is_ascending = True
    min_node_value = root.value
    max_node_value = root.value
    size = 0
    leaf_count = 0
    min_leaf_depth = 0
    max_leaf_depth = -1
    is_strict = True
    is_complete = True
    current_nodes = [root]
    non_full_node_seen = False

    while len(current_nodes) > 0:
        max_leaf_depth += 1
        next_nodes = []

        for node in current_nodes:
            size += 1
            value = node.value
            min_node_value = min(value, min_node_value)
            max_node_value = max(value, max_node_value)

            # Node is a leaf.
            if node.left is None and node.right is None:
                if min_leaf_depth == 0:
                    min_leaf_depth = max_leaf_depth
                leaf_count += 1

            if node.left is not None:
                if node.left.value > value:
                    is_descending = False
                elif node.left.value < value:
                    is_ascending = False
                next_nodes.append(node.left)
                is_complete = not non_full_node_seen
            else:
                non_full_node_seen = True

            if node.right is not None:
                if node.right.value > value:
                    is_descending = False
                elif node.right.value < value:
                    is_ascending = False
                next_nodes.append(node.right)
                is_complete = not non_full_node_seen
            else:
                non_full_node_seen = True

            # If we see a node with only one child, it is not strict
            is_strict &= (node.left is None) == (node.right is None)

        current_nodes = next_nodes

    return {
        'height': max_leaf_depth,
        'size': size,
        'is_max_heap': is_complete and is_descending,
        'is_min_heap': is_complete and is_ascending,
        'is_perfect': leaf_count == 2 ** max_leaf_depth,
        'is_strict': is_strict,
        'is_complete': is_complete,
        'leaf_count': leaf_count,
        'min_node_value': min_node_value,
        'max_node_value': max_node_value,
        'min_leaf_depth': min_leaf_depth,
        'max_leaf_depth': max_leaf_depth,
    }
929801
def get_nodes(environment=None):
    """"""
    if not os.path.exists('nodes'):
        return []
    nodes = []
    for filename in sorted(
            [f for f in os.listdir('nodes')
             if (not os.path.isdir(f)
                 and f.endswith(".json") and not f.startswith('.'))]):
        fqdn = ".".join(filename.split('.')[:-1])  # Remove .json from name
        node = get_node(fqdn)
        if environment is None or node.get('chef_environment') == environment:
            nodes.append(node)
    return nodes
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]
813510
public static List<Object> getLeafNodes(TreeModel treeModel, Object node)
    {
        List<Object> leafNodes = new ArrayList<Object>();
        getLeafNodes(treeModel, node, leafNodes);
        return leafNodes;
    }
463768
def get_children(self,node):
    
    if self.find_cycle() or self.__directionless:
      sys.stderr.write("ERROR: do cannot find a branch when there are cycles in the graph\n")
      sys.exit()
    v = self.__get_children(node.id)
    return [self.__nodes[i] for i in v]
23041
def is_leaf(self):
        
        return (not self.data) or \
               (all(not bool(c) for c, p in self.children))
605932
def get_gene_leaves(graph) -> Iterable[BaseEntity]:
    
    for node in get_nodes_by_function(graph, GENE):
        if graph.in_degree(node) != 0:
            continue

        if graph.out_degree(node) != 1:
            continue

        _, _, d = list(graph.out_edges(node, data=True))[0]

        if d[RELATION] == TRANSCRIBED_TO:
            yield node
1302684
def leaves(self, prefix=None):
        
        prefix = coalesce(prefix, "")
        output = []
        for k, v in self.items():
            if _get(v, CLASS) in data_types:
                output.extend(wrap(v).leaves(prefix=prefix + literal_field(k) + "."))
            else:
                output.append((prefix + literal_field(k), v))
        return output
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
322531
def nodes_dump(self):
        """"""
        self._flush_nodes()
        for (graph, node, branch, turn,tick, extant) in self.sql('nodes_dump'):
            yield (
                self.unpack(graph),
                self.unpack(node),
                branch,
                turn,
                tick,
                bool(extant)
            )
596484
def roots(self):
      """"""
      return [x for x in self._nodes.values() if x.id not in self._c2p]
632134
def __get_v_tree_consistent_leaf_based_hashable_multicolors(self):
        
        result = []
        nodes = deque([self.__root])
        while len(nodes) > 0:
            current_node = nodes.popleft()
            children = current_node.children
            nodes.extend(children)
            if not current_node.is_leaf():
                leaves = filter(lambda node: node.is_leaf(), current_node.get_descendants())
                result.append(Multicolor(*[self.__leaf_wrapper(leaf.name) for leaf in leaves]))
            else:
                result.append(Multicolor(self.__leaf_wrapper(current_node.name)))
        result.append(Multicolor())
        return result
695522
def get_rna_leaves(graph) -> Iterable[BaseEntity]:
    
    for node in get_nodes_by_function(graph, RNA):
        if graph.in_degree(node) != 0:
            continue

        if graph.out_degree(node) != 1:
            continue

        _, _, d = list(graph.out_edges(node, data=True))[0]

        if d[RELATION] == TRANSLATED_TO:
            yield node
474769
def get_children(self):
        """"""
        if self.is_leaf():
            return get_result_class(self.__class__).objects.none()
        return get_result_class(self.__class__).objects.filter(
            depth=self.depth + 1,
            path__range=self._get_children_path_interval(self.path)
        ).order_by(
            'path'
        )