Pre-order search of the tree rooted at this node.
        (First visit current node, then visit children.)

        :rtype: generator of :class:`~aeneas.tree.Tree`
174591
def pre(self):
        
        yield self
        for node in self.children:
            for v in node.pre:
                yield v
1284810
def as_tree(self):
        ""
        if self._nodes is None:
            return [self]
        ret = [self]
        for node in self._nodes:
            ret.append(node.as_tree())
        return ret
1251275
public List<Node> searchSubtree(Dn parent) throws NoSuchNodeException, MissingParentException {
        SearchCursor cursor = searchOneLevel(parent);
        return extractNodesFromCursor(cursor);
    }
1002953
def traverse(self, node):
    
    self.find_and_replace(node)

    for c in node.children:
      self.traverse(c)
848832
def get_children_treepos(self, treepos):
        """"""
        children_treepos = []
        for i, child in enumerate(self.dgtree[treepos]):
            if isinstance(child, nltk.Tree):
                children_treepos.append(child.treeposition())
            elif is_leaf(child):
                # we can't call .treeposition() on a leaf node
                treepos_list = list(treepos)
                treepos_list.append(i)
                leaf_treepos = tuple(treepos_list)
                children_treepos.append(leaf_treepos)
        return children_treepos
1356042
public static Treenode search(Treenode start, String text, ITreenodeSearch search) {
        return search(start.getTreeview(), text, search);
    }
434325
def iter_prepostorder(self, is_leaf_fn=None):
        
        to_visit = [self]
        if is_leaf_fn is not None:
            _leaf = is_leaf_fn
        else:
            _leaf = self.__class__.is_leaf

        while to_visit:
            node = to_visit.pop(-1)
            try:
                node = node[1]
            except TypeError:
                # PREORDER ACTIONS
                yield (False, node)
                if not _leaf(node):
                    # ADD CHILDREN
                    to_visit.extend(reversed(node.children + [[1, node]]))
            else:
                #POSTORDER ACTIONS
                yield (True, node)
367803
def walk_preorder(self):
        """"""
        yield self
        for child in self._children():
            for descendant in child.walk_preorder():
                yield descendant
472690
def previousSibling(self) -> Optional[AbstractNode]:
        
        parent = self.parentNode
        if parent is None:
            return None
        return parent.childNodes.item(parent.childNodes.index(self) - 1)
326811
def ipostorder(self):
        ''''''
        children = [self, ]
        seen = set()
        while children:
            cur_node = children[-1]
            if cur_node not in seen:
                seen.add(cur_node)
                children.extend(reversed(cur_node.children))
            else:
                children.pop()
                yield cur_node
760325
def walk_tree(start, attr):
    
    path = [start]
    for child in path:
        yield child
        idx = path.index(child)
        for grandchild in reversed(getattr(child, attr)):
            path.insert(idx + 1, grandchild)
2744
def iter_search_nodes(self, **conditions):
        
        for n in self.traverse():
            conditions_passed = 0
            for key, value in six.iteritems(conditions):
                if hasattr(n, key) and getattr(n, key) == value:
                    conditions_passed +=1
            if conditions_passed == len(conditions):
                yield n
1127846
def bft(self):
        
        queue = deque([self])
        while queue:
            node = queue.pop()
            yield node
            if hasattr(node, "childs"):
                queue.extendleft(node.childs)
1237120
def bsp_traverse_pre_order(
    node: tcod.bsp.BSP,
    callback: Callable[[tcod.bsp.BSP, Any], None],
    userData: Any = 0,
) -> None:
    
    _bsp_traverse(node.pre_order(), callback, userData)
294052
function search(root, test, skip, callback) {
  var index = -1
  var children = root.children
  var length = children.length
  var depth = null
  var start = null
  var end = null
  var nodes
  var clean
  var child

  while (++index < length) {
    child = children[index]

    if (closing(child, depth)) {
      end = index
      break
    }

    if (opening(child, depth, test)) {
      start = index
      depth = child.depth
    }
  }

  if (start !== null) {
    if (end === null) {
      end = length
    }

    if (skip) {
      while (end > start) {
        child = children[end - 1]

        if (!definition(child)) {
          break
        }

        end--
      }
    }

    nodes = callback(
      children[start],
      children.slice(start + 1, end),
      children[end],
      {
        parent: root,
        start: start,
        end: children[end] ? end : null
      }
    )

    clean = []
    index = -1
    length = nodes && nodes.length

    // Ensure no empty nodes are inserted.  This could be the case if `end` is
    // in `nodes` but no `end` node exists.
    while (++index < length) {
      if (nodes[index]) {
        clean.push(nodes[index])
      }
    }

    if (nodes) {
      splice.apply(children, [start, end - start + 1].concat(clean))
    }
  }
}
120791
def iter_ancestors(self):
        
        node = self
        while node.up is not None:
            yield node.up
            node = node.up
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