Iterative approach, using an explicit stack.

public int sumOfLeftLeaves(TreeNode root){ Stack<TreeNode> stack = new Stack<>(); TreeNode curr = root; int sum = 0; while(!stack.isEmpty() || curr != null){ while(curr != null){ stack.push(curr); curr = curr.left; if(isLeaf(curr)) { sum += curr.val; } } curr = stack.pop(); curr = curr.right; } return sum; } private boolean isLeaf(TreeNode curr){ return curr != null && curr.left == null && curr.right == null; }