title: Sum of Left Child in a Binary Search Tree
body: <p>I have the following code which replaces each node in a Binary Search Tree with the sum of its children.</p>
  
  <pre><code>public static void sumofChild(Node root) {
      if (root == null) return;
      sumofChild(root.getLeft());
      sumofChild(root.getRight());
      if (root.getLeft() != null) {
          int sum = root.getData() + root.getLeft().getData();
          root.setData(sum);
      }
      if (root.getRight() != null) {
          int sum = root.getData() + root.getRight().getData();
          root.setData(sum);
      }
  }
  </code></pre>
  
  <p>Now I wish to modify this code to update each node with only the sum of its left children. </p>
  
  <p>So essentially if this is my input tree,</p>
  
  <pre><code>   12 
    9 14
  7 10 13 17
  </code></pre>
  
  <p>The output tree needs to be,</p>
  
  <pre><code>    28
    16 27
  7 10 13 17
  </code></pre>
  
  <p>I can't seem to get it right. Any help appreciated.</p>