```
class Solution(object):
def sumOfLeftLeaves(self, root):
self.ans = 0
def dfs(r, d):
if not r:
return
if not r.left and not r.right and d:
self.ans += r.val
dfs(r.left, 1)
dfs(r.right, 0)
dfs(root, 0)
return self.ans
```