Using recursion:

- Find the number in left subtree
- Find the number in right subtree
- Sum the above two numbers and return the result

```
public class Solution {
private int sum(TreeNode root, int sum) {
if( root == null ) return 0;
sum = (sum*10) + root.val;
if ( root.left == null && root.right == null ) return sum;
int lSum = sum(root.left, sum);
int rSum = sum(root.right, sum);
return lSum+rSum;
}
public int sumNumbers(TreeNode root) {
if (root==null) return 0;
return sum(root, 0);
}
}
```