findParent<T extends TreeData> static method

bool findParent<T extends TreeData>(
  1. List<TreeVO<T>> list,
  2. TreeVO<T> treeVO
)

Implementation

static bool findParent<T extends TreeData>(List<TreeVO<T>> list, TreeVO<T> treeVO) {
  for (TreeVO<T> v in list) {
    if (v.data!.id == treeVO.data!.pid) {
      v.children.add(treeVO);
      treeVO.parent = v;
      return true;
    }
    if (v.children.length > 0) {
      if (findParent(v.children, treeVO)) {
        return true;
      }
    }
  }
  return false;
}