public void loadLeavesInSubtree(int node,List<Integer> leaves){
  if (node < 0) {
    leaves.add(~node);
  }
 else {
    loadLeavesInSubtree(leftChild[node],leaves);
    loadLeavesInSubtree(rightChild[node],leaves);
  }
}

public void loadLeavesInSubtree ( int node , List < Integer > leaves ) { if ( node < 0 ) { leaves . add ( ~ node ) ; } else { loadLeavesInSubtree ( leftChild [ node ] , leaves ) ; loadLeavesInSubtree ( rightChild [ node ] , leaves ) ; } }
extracts the list of leaves that belong to the subtree which which has ' node ' as its root . the result is added to ' leaves ' input list .
