```
int sum(int n, TreeNode* node) {
if (!node) return 0;
if (n == 1 && !node->left && !node->right) {
return node->val;
}
return sum(1, node->left) + sum(2, node->right);
}
int sumOfLeftLeaves(TreeNode* root) {
return sum(0, root);
}
```