findTreeWithId<T extends AbsNodeType> function

TreeType<T>? findTreeWithId<T extends AbsNodeType>(
  1. TreeType<T> tree,
  2. dynamic id
)

Implementation

TreeType<T>? findTreeWithId<T extends AbsNodeType>(
    TreeType<T> tree, dynamic id) {
  if (tree.data.id == id) {
    return tree;
  } else {
    for (var innerTree in tree.children) {
      TreeType<T>? recursionResult = findTreeWithId(innerTree, id);
      if (recursionResult != null) return recursionResult;
    }
  }
  return null;
}