Consider using memory_graph to visualize your data so you have a better understanding of it.
import memory_graph as mg # see link above for install instructions
class Tree(object):
def __init__(self):
self.left = None
self.data = 0
self.right = None
def insert(self,num):
self.data = self.data + 1
if num == 0:
if self.left == None:
self.left = Tree()
return self.left
elif num == 1:
if self.right == None:
self.right = Tree()
return self.right
data = [[0,1,0,0,1],[0,0,1],[0,0],[0,1,1,1,0]]
root = Tree()
for route in data:
build_tree = root
for i in range (0,len(route)):
num = route[i]
build_tree = build_tree.insert(num)
mg.show(locals()) # graph all local variables
Full disclosure: I am the developer of memory_graph.