```
class Solution(object):
def sortedArrayToBST(self, nums):
first = 0
last = len(nums) - 1
mid = len(nums) // 2
if first > last:
return
root = TreeNode(nums[mid])
root.left = self.sortedArrayToBST(nums[:mid])
root.right = self.sortedArrayToBST(nums[mid+1:])
return root
```