Commit d1adc0ce authored by di68kap's avatar di68kap
Browse files

Merge remote-tracking branch 'origin/development' into development

parents 393a5e2c 2c9ea16d
......@@ -665,7 +665,8 @@ class Node(
density=1, inline_fn=inlining)
def select(self, match_function: Callable, include_root: bool=False) -> Iterator['Node']:
def select(self, match_function: Callable, include_root: bool=False, reverse: bool=False) \
-> Iterator['Node']:
Finds nodes in the tree that fulfill a given criterion.
......@@ -680,14 +681,17 @@ class Node(
object as argument and returns True or False
include_root (bool): If False, only descendant nodes will be
checked for a match.
reverse (bool): If True, the tree will be walked in reverse
order, i.e. last children first.
Node: All nodes of the tree for which
``match_function(node)`` returns True
if include_root and match_function(self):
yield self
for child in self.children:
for node in, True):
child_iterator = reversed(self.children) if reverse else self.children
for child in child_iterator:
for node in, True, reverse):
yield node
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment