Returns an Iterator over the entire tree

@param btree    the tree to iterate over
@param forwards if false, the iterator will start at the end and move backwards
@param <V>
@return
439894
public static <V> Cursor<V, V> slice(Object[] btree, boolean forwards)
    {
        Cursor<V, V> r = new Cursor<>();
        r.reset(btree, forwards);
        return r;
    }
591689
public final FluentIterable<T> inOrderTraversal(final T root) {
    checkNotNull(root);
    return new FluentIterable<T>() {
      @Override
      public UnmodifiableIterator<T> iterator() {
        return new InOrderIterator(root);
      }
    };
  }
639217
function createEdgeIteratorForNode(type, direction, nodeData) {
  let iterator = Iterator.empty();

  if (type !== 'undirected') {
    if (direction !== 'out' && typeof nodeData.in !== 'undefined')
      iterator = chain(iterator, createIterator(nodeData.in));
    if (direction !== 'in' && typeof nodeData.out !== 'undefined')
      iterator = chain(iterator, createIterator(nodeData.out));
  }

  if (type !== 'directed' && typeof nodeData.undirected !== 'undefined') {
    iterator = chain(iterator, createIterator(nodeData.undirected));
  }

  return iterator;
}
597050
@Override
	@Pure
	public GraphIterator<RoadSegment, RoadConnection> depthIterator(
			double depth, double position_from_starting_point,
			RoadConnection starting_point, boolean allowManyReplies,
			boolean assumeOrientedSegments) {
		RoadConnection pt = starting_point.getWrappedRoadConnection();

		if ((pt == null)
				|| ((!getBeginPoint(StandardRoadConnection.class).equals(pt))
						&& (!getEndPoint(StandardRoadConnection.class).equals(pt)))) {
			pt = getBeginPoint(StandardRoadConnection.class);
		}

		return new DistanceBasedRoadNetworkIterator(
				getRoadNetwork(),
				depth, position_from_starting_point,
				this, pt,
				allowManyReplies, assumeOrientedSegments);
	}
160262
public Iterator<BplusTree.TreeEntry<K, V>> iterator() {
		return new TreeIterator<BplusTree.TreeEntry<K, V>>(this);
	}
1240290
public List<T> next(T node) {
	List<T> sons = new ArrayList<T>();
	if(left(node) != null) sons.add(left(node));
	if(right(node) != null) sons.add(right(node));
	return sons;
    }
304636
public void write(Tree<?, ?> tree) throws IOException {
        this.writer.append("digraph G"); //$NON-NLS-1$
        this.writer.append(Integer.toString(this.graphIndex++));
        this.writer.append(" {\n"); //$NON-NLS-1$

        if (tree != null) {
            // Write the node attributes
            Iterator<? extends TreeNode<?, ?>> iterator = tree.broadFirstIterator();
            TreeNode<?, ?> node;
            int dataCount;
            while (iterator.hasNext()) {
                node = iterator.next();
                dataCount = node.getUserDataCount();
                final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
                final String label = Integer.toString(dataCount);

                this.writer.append("\t"); //$NON-NLS-1$
                this.writer.append(name);
                this.writer.append(" [label=\""); //$NON-NLS-1$
                this.writer.append(label);
                this.writer.append("\"]\n"); //$NON-NLS-1$
            }

            this.writer.append("\n"); //$NON-NLS-1$

            // Write the node links
            iterator = tree.broadFirstIterator();
            Class<? extends Enum<?>> partitionType;
            TreeNode<?, ?> child;
            String childName;
            while (iterator.hasNext()) {
                node = iterator.next();
                final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
                if (!node.isLeaf()) {
                    partitionType = node.getPartitionEnumeration();
                    final int childCount = node.getChildCount();
                    for (int i = 0; i < childCount; ++i) {
                        child = node.getChildAt(i);
                        if (child != null) {
                            childName = "NODE" + Integer.toHexString(System.identityHashCode(child)); //$NON-NLS-1$
                            final String label;
                            if (partitionType != null) {
                                label = partitionType.getEnumConstants()[i].name();
                            } else {
                                label = Integer.toString(i);
                            }
                            this.writer.append("\t"); //$NON-NLS-1$
                            this.writer.append(name);
                            this.writer.append("->"); //$NON-NLS-1$
                            this.writer.append(childName);
                            this.writer.append(" [label=\""); //$NON-NLS-1$
                            this.writer.append(label);
                            this.writer.append("\"]\n"); //$NON-NLS-1$
                        }
                    }
                }
            }
        }

        this.writer.append("}\n\n"); //$NON-NLS-1$
    }
911092
def iter_predecessors(self, graph, dest, branch, turn, tick, *, forward=None):
        """"""
        if self.db._no_kc:
            yield from self._adds_dels_sucpred(self.predecessors[graph, dest], branch, turn, tick)[0]
            return
        if forward is None:
            forward = self.db._forward
        yield from self._get_origcache(graph, dest, branch, turn, tick, forward=forward)
1049796
static <K,V> TreeMapEntry<K,V> predecessor(TreeMapEntry<K,V> t) {
        if (t == null)
            return null;
        else if (t.left != null) {
            TreeMapEntry<K,V> p = t.left;
            while (p.right != null)
                p = p.right;
            return p;
        } else {
            TreeMapEntry<K,V> p = t.parent;
            TreeMapEntry<K,V> ch = t;
            while (p != null && ch == p.left) {
                ch = p;
                p = p.parent;
            }
            return p;
        }
    }
224435
public Iterator iterator() {
        return new Iterator() {
            private LeftTupleSinkNode currentNode = null;
            private LeftTupleSinkNode nextNode    = getFirst();

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

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

            public void remove() {
                if ( this.currentNode != null ) {
                    LeftTupleSinkNodeList.this.remove( this.currentNode );
                    this.currentNode = null;
                } else {
                    throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
                }
            }
        };
    }
682159
public Iterator breadthFirst() {
        return new Iterator() {
            private final List list = new LinkedList();
            private Iterator iter = iterator();
            private GPathResult next = getNextByBreadth();

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

            public Object next() {
                try {
                    return this.next;
                } finally {
                    this.next = getNextByBreadth();
                }
            }

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

            private GPathResult getNextByBreadth() {
                List children = new ArrayList();
                while (this.iter.hasNext() || !children.isEmpty()) {
                    if (this.iter.hasNext()) {
                        final GPathResult node = (GPathResult) this.iter.next();
                        this.list.add(node);
                        this.list.add(this.iter);
                        children.add(node.children());
                    } else {
                        List nextLevel = new ArrayList();
                        for (Object child : children) {
                            GPathResult next = (GPathResult) child;
                            Iterator iterator = next.iterator();
                            while (iterator.hasNext()) {
                                nextLevel.add(iterator.next());
                            }
                        }
                        this.iter = nextLevel.iterator();
                        children = new ArrayList();
                    }
                }
                if (this.list.isEmpty()) {
                    return null;
                } else {
                    GPathResult result = (GPathResult) this.list.get(0);
                    this.list.remove(0);
                    this.iter = (Iterator) this.list.get(0);
                    this.list.remove(0);
                    return result;
                }
            }
        };
    }
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()." );
                }
            }
        };
    }
865996
public Node<T> getNext(Node<T> node) {
    	if (node.right != null) {
    		node = node.right;
    		while (node.left != null) node = node.left;
    		return node;
    	}
    	// nothing at right, it may be the parent node if the node is at the left
    	if (node == last) return null;
    	return getNext(root, node.value);
    }
130557
public QuadTreeIterator getIterator(boolean bSorted) {
		if (!bSorted) {
			QuadTreeImpl.QuadTreeIteratorImpl iterator = m_impl.getIterator();
			return new QuadTreeIterator(iterator, false);
		} else {
			QuadTreeImpl.QuadTreeSortedIteratorImpl iterator = m_impl.getSortedIterator();
			return new QuadTreeIterator(iterator, true);
		}
	}
768061
function forwardSearch() {
      cameFrom = open1Set.pop();
      if (cameFrom.closed) {
        return;
      }

      cameFrom.closed = true;

      if (cameFrom.f1 < lMin && (cameFrom.g1 + f2 - heuristic(from, cameFrom.node)) < lMin) {
        graph.forEachLinkedNode(cameFrom.node.id, forwardVisitor);
      }

      if (open1Set.length > 0) {
        // this will be used in reverse search
        f1 = open1Set.peek().f1;
      } 
    }
585533
def breadth_each(max_depth=999,&block)
      node_queue = [self] # Create a queue with self as the initial entry

      # Use a queue to do breadth traversal
      until node_queue.empty?
        node_to_traverse = node_queue.shift
        yield node_to_traverse
        # Enqueue the children from left to right.
        node_to_traverse.children { |child| node_queue.push child }
        max_depth -= 1
        break if max_depth == 0
      end
    end
325169
public static ArrayList<MtasTreeHit<?>> searchMtasTree(int position,
      IndexInput in, long ref, long objectRefApproxOffset) throws IOException {
    return searchMtasTree(position, position, in, ref, objectRefApproxOffset);
  }