GET Parent pointer whose right child is not a parent or itself of this node . There might be case when parent has no right child , but , current node is left child of the parent ( second condition is for that ) .
while ( node . parent . right == node || ( node . parent . right == null && node . parent . left == node ) ) { if ( node . parent == null ) return null ; node = node . parent ; level -- ; }