Python preorder iterative
\n\nclass Solution(object):\n    def sortedArrayToBST(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: TreeNode\n        \n        """\
```\n\nclass Solution(object):\n    def sortedArrayToBST(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: TreeNode\n        \n        """\n        if not nums: return None\n        \n        l = 0\n        r = len(nums)\n        m = (l+r)/2\n        root = TreeNode(nums[m])\n        stack = [(root,l,m,r)]\n        while stack:\n            node, l, m, r = stack.pop()\n            if r!=m+1:\n                node.right = TreeNode(nums[(r+m+1)/2])\n                stack.append((node.right,m+1,(r+m+1)/2,r))\n            if l!=m:\n                node.left = TreeNode(nums[(l+m)/2])\n                stack.append((node.left,l,(l+m)/2,m))\n                \n        return root\n```
[]