I got below errors

AttributeError: 'NoneType' object has no attribute 'val'

I am using below codes and it works on my mac. any idea?

```
class Solution:
# @param root, a tree node
# @return a list of integers
def preorderTraversal(self, root):
stack = []
result = []
stack.append(root)
while len(stack) != 0 :
node = stack.pop()
result.append(node.val)
print "Node value " + repr(node)
print "Node value val " + repr(node.val)
print "Node value L " + repr(node.left)
print "Node value R " + repr(node.right)
if node.right != None :
stack.append(node.right)
print "Append R"
if node.left != None :
stack.append(node.left)
print "Append L"
return result
```