My solution to preorder traversal using iterative method

'''

```
def preorderTraversal(self, root):
stack = []
ret = []
stack.append(root)
if (root == None):
return ret
while(len(stack)>0):
node = stack.pop()
ret.append(node.val)
if(node.right != None):
stack.append(node.right)
if(node.left != None):
stack.append(node.left)
return ret
```

'''