```
class Solution(object):
def sumNumbers(self, root):
num, self.Total=0,0
return self.dfs(root, num)
def dfs(self, root, num):
if not root:
return 0
else:
num*=10
num+=root.val
if not root.left and not root.right:
self.Total+=num
for item in [root.left, root.right]:
if item:
self.dfs(item, num)
return self.Total
```