```
class Solution:
# @param head, a list node
# @return a tree node
def sortedArrayToBST(self, num):
if len(num) == 0:
return None
mid = len(num)//2
current = TreeNode(num[mid])
current.left = self.sortedArrayToBST(num[:mid])
current.right = self.sortedArrayToBST(num[mid+1:])
return current
def sortedListToBST(self, head):
array = []
p = head
while head:
array.append(p.val)
p = p.next
return self.sortedArrayToBST(array)
```

I convert sorted list to an sorted array and use the previous function to solve the problem. OJ says: Line 30: AttributeError: 'NoneType' object has no attribute 'val'. I don't know what's wrong with 'array.append(p.val)'... Someone please help. Thanks a lot!!