def add_children_from_MyNode(tree_file): # add children tree = np.load(tree_file, allow_pickle=True, encoding='latin1') # a new tree with a simplified structure Tree = [] # read the npy file and put them in MyNode for i in range(len(tree)): node_ = tree[i] parent = node_.parentID ID = i Tree.append(node(ID, parent, [], False)) # update the children of its parent if parent != -1: Tree[parent].children.append(ID) # identify the leaves for i in range(len(Tree)): if len(Tree[i].children) == 0: Tree[i].is_leaf = True return Tree