if( node instanceof Root ){
return new ResizeRoot<T>( this, (Root)node );
}
if( node instanceof Node ){
Node real = (Node)node;
SplitNode left = real.getLeft();
SplitNode right = real.getRight();
boolean leftVisible = left == null ? false : left.isVisible();
boolean rightVisible = right == null ? false : right.isVisible();
if( leftVisible && rightVisible ){
return new ResizeNode<T>( this, parent, (Node)node );
}
if( leftVisible ){
return toElement( parent, left.getVisible() );
}
if( rightVisible ){
return toElement( parent, right.getVisible() );
}
return null;
}
if( node instanceof Leaf ){
return new ResizeLeaf<T>( this, parent, (Leaf)node );