In-order traversal of the tree
503162
def in_order_traverse(self):
        
        result = []

        if not self.node:
            return result

        result.extend(self.node.left.in_order_traverse())
        result.append(self.node.key)
        result.extend(self.node.right.in_order_traverse())
        return result
57811
def traverse
      # We use a non-recursive implementation to traverse the tree. This stack
      # keeps track of all the known still to be checked nodes.
      stack = [ [ self, 0 ] ]

      while !stack.empty?
        node, position = stack.pop

        # Call the payload method. The position marks where we are in the node
        # with respect to the traversal. 0 means we've just entered the node
        # for the first time and are about to descent to the first child.
        # Position 1 is after the 1st child has been processed and before the
        # 2nd child is being processed. If we have N children, the last
        # position is N after we have processed the last child and are about
        # to return to the parent node.
        yield(node, position, stack)

        if position <= node.keys.size
          # Push the next position for this node onto the stack.
          stack.push([ node, position + 1 ])

          if !node.is_leaf? && node.children[position]
            # If we have a child node for this position, push the linked node
            # and the starting position onto the stack.
            stack.push([ node.children[position], 0 ])
          end
        end
      end
    end
272031
private void traverse(GroovySourceAST t) {
        if (t == null) { return; }
        if (unvisitedNodes != null) {
           unvisitedNodes.add(t);
        }
        GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
        if (child != null) {
            traverse(child);
        }
        GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();
        if (sibling != null) {
            traverse(sibling);
        }
    }
105835
QNode traversalHead() {
    for (;;) {
      QNode t = this.tail.get();
      QNode h = this.head.get();
      if (h != null && t != null) {
        QNode last = t.next;
        QNode first = h.next;
        if (t == this.tail.get()) {
          if (last != null) {
            this.tail.compareAndSet(t, last);
          } else if (first != null) {
            Object x = first.get();
            if (x == first) {
              advanceHead(h, first);
            } else {
              return h;
            }
          } else {
            return h;
          }
        }
      }
    }
  }
777092
function tree(d, i) {
    var nodes = hierarchy.call(this, d, i),
        t = nodes[0],
        wt = wrapTree(t);

    wroot = wt;
    zerothWalk(wt, 0);
    firstWalk(wt);
    secondWalk(wt, 0);
    renormalize(wt);

    return nodes;
  }
1312355
function traverse(transform, node, parent) {
    const type = node && node.type;
    assert(type, `Expected node, got '${node}'`);

    const baseHandler = transform.handlers[type] || transform.handlers.default;
    const userHandler = transform.userHandlers[type] || transform.userHandlers.default;
    const starHandler = transform.userHandlers['*'];
    const userBaseHandler = userHandler ? userHandler.bind({ __base: baseHandler }) : baseHandler;

    const handler = starHandler ? starHandler.bind({ __base: userBaseHandler }) : userBaseHandler;

    return handler(transform, node, parent);
}
1292394
def dfs_inorder(self, reverse=False):
        """"""
        stack = deque()
        visited = set()
        visited.add(self)
        if reverse:
            stack.append(self.childs[0])
            stack.append(self)
            stack.extend(self.childs[1:])
        else:
            stack.extend(self.childs[1:])
            stack.append(self)
            stack.append(self.childs[0])
        while stack:
            node = stack.pop()
            if node in visited or not node.childs:
                yield node
            else:
                stack.append(node)
                visited.add(node)
                if hasattr(node, "childs"):
                    if reverse:
                        stack.extend(node.childs)
                    else:
                        stack.extend(node.childs[::-1])
55584
function Iterator(tree, snapshot) {
  this.tree = tree;
  this.root = snapshot;
  this.current = snapshot;
  this.key = null;
  this.value = null;
}
389689
private Tree<Row> findNext( Tree<Row> pointer ){
        if( pointer.hasNext() ){
            // The given tree-node is not the last in its block.
            if( Type.END.equals( pointer.getNext().getContent().getType() ) ){
                return null;
            }
            else{
                return pointer.getNext();
            }
        }
        // The given tree-node was last in its block. Then we return the
        // the block closing tree-node.
        Tree<Row> parent = pointer.getParent();
        Type parentType = parent.getContent().getType();
        if( Type.WHILE_DO_BEGIN.equals( parentType ) ){

            return parent.getNext();
        }
        else if( Type.DO_WHILE_BEGIN.equals( parentType ) ){
            return parent.getNext();
        }
        if( Type.BRANCH.equals( parentType ) ){
            Tree<Row> join = parent.getParent().getNext();
            return join;
        }
        else if( Type.IF.equals( parentType ) || Type.ELSE_IF.equals( parentType ) || Type.ELSE.equals( parentType ) ){
            Tree<Row> endIf = findEndIf( parent );
            return endIf;
        }
        else{
            throw new IllegalStateException( "Unknown containting block type for row " + parent.getContent() );
        }
    }
1003561
def traverse_layout(root, callback):
    
    callback(root)
    if isinstance(root, collections.Iterable):
        for child in root:
            traverse_layout(child, callback)
557430
public static void visitPreOrder(
      Node node, Visitor visitor, Predicate<Node> traverseChildrenPred) {
    visitor.visit(node);

    if (traverseChildrenPred.apply(node)) {
      for (Node c = node.getFirstChild(); c != null; c = c.getNext()) {
        visitPreOrder(c, visitor, traverseChildrenPred);
      }
    }
  }
619780
function visit( node, predecessors ) {
                //check if a node is dependent of itself
                if( predecessors.length !== 0 && predecessors.indexOf( node ) !== -1 ) {
                    throw new Error( "Cyclic dependency found. " + node + " is dependent of itself.\nDependency chain: "
                                     + predecessors.join( " -> " ) + " => " + node );
                }

                var index = nodes.indexOf( node );

                //if the node still exists, traverse its dependencies
                if( index !== -1 ) {
                    var copy = false;

                    //mark the node as false to exclude it from future iterations
                    nodes[index] = false;

                    //loop through all edges and follow dependencies of the current node
                    for( var _iterator4 = _this.edges, _isArray4 = Array.isArray( _iterator4 ), _i4 = 0, _iterator4 = _isArray4 ?
                                                                                                                      _iterator4 :
                                                                                                                      _iterator4[Symbol.iterator](); ; ) {
                        var _ref4;

                        if( _isArray4 ) {
                            if( _i4 >= _iterator4.length ) {
                                break;
                            }
                            _ref4 = _iterator4[_i4++];
                        } else {
                            _i4 = _iterator4.next();
                            if( _i4.done ) {
                                break;
                            }
                            _ref4 = _i4.value;
                        }

                        var edge = _ref4;

                        if( edge[0] === node ) {
                            //lazily create a copy of predecessors with the current node concatenated onto it
                            copy = copy || predecessors.concat( [node] );

                            //recurse to node dependencies
                            visit( edge[1], copy );
                        }
                    }

                    //add the node to the next place in the sorted array
                    sorted[--place] = node;
                }
            }
104567
def bsp_traverse_level_order(
    node: tcod.bsp.BSP,
    callback: Callable[[tcod.bsp.BSP, Any], None],
    userData: Any = 0,
) -> None:
    
    _bsp_traverse(node.level_order(), callback, userData)
777523
function traverseRecursive(rootNode, options) {
  options = extend({
    subnodesAccessor: function(node) { return node.subnodes; },
    onNode: function(node, callback, userdata) {},
    onComplete: function(rootNode) {},
    userdata: null
  }, options);

  (function visitNode(node, callback) {
    var subnodes = options.subnodesAccessor(node);
    async.eachSeries(subnodes, function(subnode, next) {
      visitNode(subnode, function() {
        async.setImmediate(next);
      });
    },
    function() {
      options.onNode(node, function() {
        async.setImmediate(callback);
      }, options.userdata);
    });
  })(rootNode, function() {
    options.onComplete(rootNode);
  });
}
558313
def traverse_tree(cls, static_dir):
        """"""
        for root, dirs, files in os.walk(static_dir):
            for filename in files:
                if cls._pattern.match(filename):
                    APPS_INCLUDE_DIRS.append(static_dir)
                    return
619109
def traverse_levelorder(self, leaves=True, internal=True):
        ''''''
        for node in self.root.traverse_levelorder(leaves=leaves, internal=internal):
            yield node
537668
def find_in_tree(tree, key, perfect=False):
    
    if len(key) == 0:
        if tree['item'] is not None:
            return tree['item'], ()
        else:
            for i in range(len(tree['subtrees'])):
                if not perfect and tree['subtrees'][i][0] == '*':
                    item, trace = find_in_tree(tree['subtrees'][i][1],
                                               (), perfect)
                    return item, (i,) + trace
            raise KeyError(key)
    else:
        head, tail = key[0], key[1:]
        for i in range(len(tree['subtrees'])):
            if tree['subtrees'][i][0] == head or \
               not perfect and tree['subtrees'][i][0] == '*':
                try:
                    item, trace = find_in_tree(tree['subtrees'][i][1],
                                               tail, perfect)
                    return item, (i,) + trace
                except KeyError:
                    pass
        raise KeyError(key)