clearChildren method
Removes all children from this node and sets their parent to null.
Returns the old children to easily move nodes to another parent.
Implementation
List<TreeNode> clearChildren() {
final _removedChildren = _children.map((child) {
child._parent = null;
return child;
}).toList(growable: false);
_children.clear();
return _removedChildren;
}