nextNodeWhere method

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

Implementation

Node? nextNodeWhere(bool Function(Node element) test) {
  for (final child in children) {
    final matchingNode = child._thisOrDescendantMatching(test);
    if (matchingNode != null) {
      return matchingNode;
    }
  }

  var next = this.next;
  while (next != null) {
    final nextDescendentMatch = next._thisOrDescendantMatching(test);
    if (nextDescendentMatch != null) {
      return nextDescendentMatch;
    }
    next = next.next;
  }

  return parent?.next?._thisOrDescendantMatching(test);
}