findDownward method

Node? findDownward(
  1. bool test(
    1. Node element
    )
)

Implementation

Node? findDownward(bool Function(Node element) test) {
  final children = this.children.toList();
  for (final child in children) {
    if (test(child)) {
      return child;
    }
    if (child.children.isNotEmpty) {
      final node = child.findDownward(test);
      if (node != null) {
        return node;
      }
    }
  }
  final next = this.next;
  if (next != null) {
    if (test(next)) {
      return next;
    }
    return next.findDownward(test);
  }
  return null;
}