src/Collection/Tree/RedBlackSearchTree.php
protected function nodeRemoveMax(RedBlackNode $node): ?RedBlackNode
    {
        if ($this->isRed($node->left())) {
            $node = $this->rotateRight($node);
        }

        if ($node->right() === null) {
            return null;
        }

        if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) {
            $node = $this->moveRedRight($node);
        }

        $node->setRight($this->nodeRemoveMax($node->right()));

        return $this->balanceOnRemove($node);
    }
protected function nodeRemoveMax(RedBlackNode $node): ?RedBlackNode
    {
        if ($this->isRed($node->left())) {
            $node = $this->rotateRight($node);
        }

        if ($node->right() === null) {
            return null;
        }

        if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) {
            $node = $this->moveRedRight($node);
        }

        $node->setRight($this->nodeRemoveMax($node->right()));

        return $this->balanceOnRemove($node);
    }
protected function nodeRemoveMax ( RedBlackNode $ node ) : ? RedBlackNode { if ( $ this -> isRed ( $ node -> left ( ) ) ) { $ node = $ this -> rotateRight ( $ node ) ; } if ( $ node -> right ( ) === null ) { return null ; } if ( ! $ this -> isRed ( $ node -> right ( ) ) && ! $ this -> isRed ( $ node -> right ( ) -> left ( ) ) ) { $ node = $ this -> moveRedRight ( $ node ) ; } $ node -> setRight ( $ this -> nodeRemoveMax ( $ node -> right ( ) ) ) ; return $ this -> balanceOnRemove ( $ node ) ; }
Removes the node with the maximum key in a subtree

@param RedBlackNode $node The subtree root

@return RedBlackNode|null
Removes the node with the maximum key in a subtree