#define pathSum(root) __pathSum(root, 0)
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
int __pathSum(struct TreeNode* root, int depth) {
if (!root) return 0;
if (!root->left && !root->right)
return root->val * depth;
return __pathSum(root->left, depth + 1) +
__pathSum(root->right, depth + 1);
}