def main():
    t = Node(10)
    t.left = Node(2)
    t.left.left = Node(1)
    t.left.right = Node(3)
    t.right = Node(20)
    t.right.right = Node(40)

    x = tree_to_linked_list(t)
    print x
    def _ordered_array_to_node(self, arr, start, end):
        # Start cannot be greater than end
        if start > end:
            return None

        mid = (start + end) / 2
        root = Node(arr[mid])
        # Populate the node structure
        root.left = self._ordered_array_to_node(arr, start, mid - 1)
        root.right = self._ordered_array_to_node(arr, mid + 1, end)

        return root