getParent method
Gets the parent of the node identified by specified key.
Implementation
Node<T>? getParent(String key, {Node<T>? parent}) {
Node<T>? _found;
List<Node<T>> _children = parent == null ? this.children : parent.children;
Iterator iter = _children.iterator;
while (iter.moveNext()) {
Node<T> child = iter.current;
if (child.key == key) {
_found = parent ?? child;
break;
} else {
if (child.isParent) {
_found = this.getParent(key, parent: child);
if (_found != null) {
break;
}
}
}
}
return _found;
}