advance method

bool advance()

Advances to the next node after the current subtree, without visiting any of the current node's descendants.

Implementation

bool advance() {
  final node = _current;
  if (node == null || _stack.isEmpty) return false;
  if (identical(_stack.last.node, node)) _stack.removeLast();
  while (_stack.isNotEmpty) {
    final parent = _stack.last;
    if (parent.nextChild < parent.node.children.length) {
      final sibling = _pushNextChild(parent);
      _stack.add(sibling.$2);
      _current = sibling.$1;
      return true;
    }
    _stack.removeLast();
  }
  _current = null;
  return false;
}