traverse method

  1. @nonVirtual
Iterable<Node> traverse({
  1. bool prune(
    1. Node node
    )?,
})
inherited

This node and its subtree, in postorder: every child before its parent, and children in reverse priority order.

prune skips a node and everything beneath it, so a walk can stop at a subtree rather than filter it out afterwards.

Implementation

@nonVirtual
Iterable<Node> traverse({bool Function(Node node)? prune}) sync* {
  if (prune != null && prune(this)) return;
  final children = _egg?.nodes;

  if (children != null && children.isNotEmpty) {
    for (final child in children.reversed) {
      yield* child.traverse(prune: prune);
    }
  }

  yield this;
}