public int recursive(TreeNode root, int sum) {
        if (root == null)
            return 0;
        if (root.left == null && root.right == null)
            return sum * 10 + root.val;
        return recursive(root.left, sum * 10 + root.val) + recursive(root.right, sum * 10 + root.val);
    }