public static <E extends Comparable<E>>void toChildrenSum(BinaryNode<E> node){
  if (node == null || node.left == null && node.right == null)   return;
  toChildrenSum(node.left);
  toChildrenSum(node.right);
  Integer nodeValue=(Integer)(node == null ? 0 : node.value);
  Integer leftChildValue=(Integer)(node.left == null ? 0 : node.left.value);
  Integer rightChildValue=(Integer)(node.right == null ? 0 : node.right.value);
  int diff=leftChildValue + rightChildValue - nodeValue;
  if (diff < 0) {
    increment(node,-diff);
  }
 else   if (diff > 0) {
  }
}

public static < E extends Comparable < E > > void toChildrenSum ( BinaryNode < E > node ) { if ( node == null || node . left == null && node . right == null ) return ; toChildrenSum ( node . left ) ; toChildrenSum ( node . right ) ; Integer nodeValue = ( Integer ) ( node == null ? 0 : node . value ) ; Integer leftChildValue = ( Integer ) ( node . left == null ? 0 : node . left . value ) ; Integer rightChildValue = ( Integer ) ( node . right == null ? 0 : node . right . value ) ; int diff = leftChildValue + rightChildValue - nodeValue ; if ( diff < 0 ) { increment ( node , - diff ) ; } else if ( diff > 0 ) { } }
converts a tree to hold the children sum invariant . < p / > it only increments data values in any node ( does not change structure of tree and cannot decrement value of any node ) .
