Returns an iterator over the leaves under this node.
960331
def iter_leaves(self, is_leaf_fn=None):
        
        for n in self.traverse(strategy="preorder", is_leaf_fn=is_leaf_fn):
            if not is_leaf_fn:
                if n.is_leaf():
                    yield n
            else:
                if is_leaf_fn(n):
                    yield n
287532
def leaves(self, cls, level=0, intermediate=False):
        
        if intermediate:
            if isinstance(self, cls):
                yield self, level
        elif len(self.children) == 0:
            if isinstance(self, cls):
                yield self, level
            else:
                raise StopIteration

        for child in self.children:
            for leaf, _level in child.leaves(cls, level + 1, intermediate=intermediate):
                    yield leaf, _level
26127
def iter_leaf_names(self, is_leaf_fn=None):
        """"""
        for n in self.iter_leaves(is_leaf_fn=is_leaf_fn):
            yield n.name
174844
def generate_child_leaf_nodes(self):
        

        def _yield_child_leaf_nodes(node):
            """

            Args:
                node:

            Yields:
            """
            if not node.has_children():
                yield node
            else:
                for child_node in node.generate_child_nodes():
                    # recursivity is not compatible with yield in Python2.x: you have to re-yield results
                    for child in _yield_child_leaf_nodes(child_node):
                        yield child

        return _yield_child_leaf_nodes(self)
55584
function Iterator(tree, snapshot) {
  this.tree = tree;
  this.root = snapshot;
  this.current = snapshot;
  this.key = null;
  this.value = null;
}
986968
def tree_iterator(self, visited=None, path=None):
        '''
        
        '''
        if visited is None:
            visited = set()

        if self not in visited:
            if path and isinstance(path, list):
                path.append(self)

            visited.add(self)
            yield self

            if not hasattr(self, 'dterms'):
                yield

            for dterm in self.dterms:
                if hasattr(self, dterm):
                    child = getattr(self, dterm)
                    if hasattr(child, 'dterms') or hasattr(child, 'terms'):
                        for node in child.tree_iterator(visited):
                            yield node
83233
def get_obs_leaves(self):
        
        obs_leaves = []
        for n in self:
            if n.is_leaf:
                if isinstance(n, ModelNode):
                    l = n.parent
                else:
                    l = n
            if l not in obs_leaves:
                obs_leaves.append(l)
        return obs_leaves
243551
public ArrayList<NaryTree> getLeaves() {
        LeafCollector leafCollector = new LeafCollector();
        postOrderTraversal(leafCollector);
        return leafCollector.leaves;
    }
769842
@Override
    public Iterator<Tree> iterator() {
        return new Iterator<Tree>() {
            @Override
            public boolean hasNext() {
                return next != null;
            }

            @Override
            public Tree next() {
                Tree t = next.leaf;
                next = next.parent;
                return t;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }

            private TreePath next = TreePath.this;
        };
    }
857180
def iter_fields(self):
        
        def generator(path, values):
            for name,value in sorted(values.items()):
                if isinstance(value, ValueTree):
                    for inner in generator(path + name, value._values):
                        yield inner
                else:
                    yield (path, name, value)
        return generator(Path([]), self._values)
671492
def leaves(tree):
    
    lvs = []
    def _leaves(node):
        if np.isscalar(node):
            lvs.append(node)
        elif isinstance(node, tuple) and len(node) == 2:
            _leaves(node[0])
            _leaves(node[1])
        else:
            raise Exception("Not a tree!")

    _leaves(tree)
    return lvs
813510
public static List<Object> getLeafNodes(TreeModel treeModel, Object node)
    {
        List<Object> leafNodes = new ArrayList<Object>();
        getLeafNodes(treeModel, node, leafNodes);
        return leafNodes;
    }
1256946
static <T> T iterate(Object o, Closure<IterateBean, Object> closure) {
        return (T)iterateNamedObjectFromLeaf(null, "", o, closure);
    }
1076010
def leaves(self, name):
        

        return list(self.lookup_leaves.get(unnest_path(name), Null))
639856
def traverse_preorder(self, leaves=True, internal=True):
        '''
        '''
        s = deque(); s.append(self)
        while len(s) != 0:
            n = s.pop()
            if (leaves and n.is_leaf()) or (internal and not n.is_leaf()):
                yield n
            s.extend(n.children)
639770
public Iterator iterator() {
        return new Iterator() {
            private ObjectSinkNode currentNode = null;
            private ObjectSinkNode nextNode    = getFirst();

            public boolean hasNext() {
                return (this.nextNode != null);
            }

            public Object next() {
                this.currentNode = this.nextNode;
                if ( this.currentNode != null ) {
                    this.nextNode = this.currentNode.getNextObjectSinkNode();
                } else {
                    throw new NoSuchElementException( "No more elements to return" );
                }
                return this.currentNode;
            }

            public void remove() {
                if ( this.currentNode != null ) {
                    ObjectSinkNodeList.this.remove( this.currentNode );
                    this.currentNode = null;
                } else {
                    throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
                }
            }
        };
    }
240296
def n_leaves(neurites, neurite_type=NeuriteType.all):
    ''''''
    return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)