findDownward method
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;
}