public void remove ( String suggestion ) { Node n = getNode ( suggestion ) ; if ( n == null ) return ; n . weight = - 1 ; size -- ; Node m = n ; if ( n . mid == null ) { Node replacement = removeNode ( n ) ; if ( replacement != null ) replacement . parent = n . parent ; if ( n == root ) root = replacement ; else if ( n == n . parent . mid ) n . parent . mid = replacement ; else { if ( n == n . parent . left ) n . parent . left = replacement ; else n . parent . right = replacement ; while ( n != root && n != n . parent . mid ) n = n . parent ; } n = n . parent ; if ( n == null ) return ; } if ( n . weight == - 1 && n . mid . left == null && n . mid . right == null ) { n = mergeWithChild ( n ) ; while ( n != root && n != n . parent . mid ) n = n . parent ; n = n . parent ; if ( n == null ) return ; } removeFromLists ( m , n ) ; }
Removes the specified suggestion from this tree if present .