code: private void adaptForRemove(final ITreeStructData pOldNode) throws TTException {
          assert pOldNode != null;
  
          // Adapt left sibling node if there is one.
          if (pOldNode.hasLeftSibling()) {
              final ITreeStructData leftSibling = (ITreeStructData)getPtx().getData(pOldNode.getLeftSiblingKey());
              leftSibling.setRightSiblingKey(pOldNode.getRightSiblingKey());
              getPtx().setData(leftSibling);
          }
  
          // Adapt right sibling node if there is one.
          if (pOldNode.hasRightSibling()) {
              final ITreeStructData rightSibling = (ITreeStructData)getPtx().getData(pOldNode.getRightSiblingKey());
              rightSibling.setLeftSiblingKey(pOldNode.getLeftSiblingKey());
              getPtx().setData(rightSibling);
          }
  
          // Adapt parent, if node has now left sibling it is a first child.
          final ITreeStructData parent = (ITreeStructData)getPtx().getData(pOldNode.getParentKey());
          if (!pOldNode.hasLeftSibling()) {
              parent.setFirstChildKey(pOldNode.getRightSiblingKey());
          }
          parent.decrementChildCount();
          getPtx().setData(parent);
  
          if (pOldNode.getKind() == IConstants.ELEMENT) {
              // removing attributes
              for (int i = 0; i < ((ElementNode)pOldNode).getAttributeCount(); i++) {
                  moveTo(((ElementNode)pOldNode).getAttributeKey(i));
                  getPtx().removeData(mDelegate.getCurrentNode());
              }
              // removing namespaces
              moveTo(pOldNode.getDataKey());
              for (int i = 0; i < ((ElementNode)pOldNode).getNamespaceCount(); i++) {
                  moveTo(((ElementNode)pOldNode).getNamespaceKey(i));
                  getPtx().removeData(mDelegate.getCurrentNode());
              }
          }
  
          // Remove old node.
          getPtx().removeData(pOldNode);
      }
docs: Adapting everything for remove operations.
  
  @param pOldNode
  pointer of the old node to be replaces
  @throws TTIOException
  if anything weird happens