previousNodeWhere method
Returns the first previous node in the subtree that satisfies the given predicate
Implementation
Node? previousNodeWhere(bool Function(Node element) test) {
var previous = this.previous;
while (previous != null) {
final last = previous.lastChildWhere(test);
if (last != null) {
return last;
}
if (test(previous)) {
return previous;
}
previous = previous.previous;
}
final parent = this.parent;
if (parent != null) {
if (test(parent)) {
return parent;
}
return parent.previousNodeWhere(test);
}
return null;
}