```
class Solution:
# @param root, a tree node
# @return an integer
def sumNumbers(self, root):
if root == None:
return 0
sum = 0
stack = []
stack.append((root, 0))
while stack != []:
unit = stack.pop()
node, val = unit
val += node.val
val *= 10
if node.left == None and node.right == None:
sum += (val/10)
if node.right != None:
stack.append((node.right, val))
if node.left != None:
stack.append((node.left, val))
return sum
```

I think it is better to use non-recursive methods to handle this problem.