```
class Solution:
# @param root, a tree node
# @param sum, an integer
# @return a boolean
def hasPathSum(self, root, sum):
node = root
if node.left==None and node.right==None and sum==node.val:
return True
if node.left != None:
node = node.left
hasPathSum(self, node, sum-node.val)
if node.right != None:
node = node.right
hasPathSum(self, node, sum-node.val)
return False
```

Here is the error message:

Runtime Error Message: Line 16: AttributeError: 'NoneType' object has no attribute 'left'

Last executed input: {}, 1

I just want to know how to fix it, thanks!