publicstaticvoidleftSum(Node root, Node parent) {
if (root ==null) {
return 0;
}
// if left node is present and is a leafif (root.left!=null&& root.left.left==null&& root.left.right==null) {
return root.left.val+ sumOfLeftLeaves(root.right);
}
return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);
}