private byte[] removeFromTree(byte[] key,Node node) throws IOException {
  byte[] value=null;
  int valueIdx=node.search(key);
  if (valueIdx >= 0) {
    if (node.isLeaf()) {
      value=node.removeValueRight(valueIdx);
    }
 else {
      value=node.getValue(valueIdx);
      Node leftChildNode=node.getChildNode(valueIdx);
      byte[] largestValue=removeLargestValueFromTree(leftChildNode);
      node.setValue(valueIdx,largestValue);
      balanceChildNode(node,leftChildNode,valueIdx);
      leftChildNode.release();
    }
  }
 else   if (!node.isLeaf()) {
    valueIdx=-valueIdx - 1;
    Node childNode=node.getChildNode(valueIdx);
    value=removeFromTree(key,childNode);
    balanceChildNode(node,childNode,valueIdx);
    childNode.release();
  }
  return value;
}

private byte [ ] removeFromTree ( byte [ ] key , Node node ) throws IOException { byte [ ] value = null ; int valueIdx = node . search ( key ) ; if ( valueIdx >= 0 ) { if ( node . isLeaf ( ) ) { value = node . removeValueRight ( valueIdx ) ; } else { value = node . getValue ( valueIdx ) ; Node leftChildNode = node . getChildNode ( valueIdx ) ; byte [ ] largestValue = removeLargestValueFromTree ( leftChildNode ) ; node . setValue ( valueIdx , largestValue ) ; balanceChildNode ( node , leftChildNode , valueIdx ) ; leftChildNode . release ( ) ; } } else if ( ! node . isLeaf ( ) ) { valueIdx = - valueIdx - 1 ; Node childNode = node . getChildNode ( valueIdx ) ; value = removeFromTree ( key , childNode ) ; balanceChildNode ( node , childNode , valueIdx ) ; childNode . release ( ) ; } return value ; }
removes the value that matches the specified key from the tree starting at the specified node and returns the removed value .
