search_tree = [ [ [[],'B',[]], 'A', [[],'C',[]] ], 'S', [ [ [[],'F',[]], 'E', [[],'G',[]] ], 'D', [ [[],'I',[]], 'H', [[],'J',[]] ] ] ] open_list = [search_tree,] while open_list: x = open_list.pop(0) print x[1], if x[1] == 'G': print ' **Goal**', break if x[0]: open_list.append(x[0]) if x[2]: open_list.append(x[2]) print