list of list to tree python code example
Example: convert list to tree python
def normalize(tree, row=0, col=0):
try:
node = tree[row][col]
left = normalize(tree, row+1, col*2)
right = normalize(tree, row+1, col*2+1)
return [node, left, right] if left or right else [node]
except:
return None # child index does not exist