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 node -> parent -> parent == NULL ) return NULL ; node = node -> parent ; level -- ; }