TreeType<T> findRoot<T extends AbsNodeType>(TreeType<T> tree) { if (tree.isRoot) return tree; return findRoot(tree.parent!); }