src/Collection/Tree/RedBlackSearchTree.php
protected function nodeSelect(int $rank, RedBlackNode $node): RedBlackNode
    {
        $size = $this->nodeSize($node->left());

        if ($size > $rank) {
            return $this->nodeSelect($rank, $node->left());
        }
        if ($size < $rank) {
            return $this->nodeSelect($rank - $size - 1, $node->right());
        }

        return $node;
    }
protected function nodeSelect(int $rank, RedBlackNode $node): RedBlackNode
    {
        $size = $this->nodeSize($node->left());

        if ($size > $rank) {
            return $this->nodeSelect($rank, $node->left());
        }
        if ($size < $rank) {
            return $this->nodeSelect($rank - $size - 1, $node->right());
        }

        return $node;
    }
protected function nodeSelect ( int $ rank , RedBlackNode $ node ) : RedBlackNode { $ size = $ this -> nodeSize ( $ node -> left ( ) ) ; if ( $ size > $ rank ) { return $ this -> nodeSelect ( $ rank , $ node -> left ( ) ) ; } if ( $ size < $ rank ) { return $ this -> nodeSelect ( $ rank - $ size - 1 , $ node -> right ( ) ) ; } return $ node ; }
Retrieves the node with the key of a given rank in a subtree

@param int          $rank The rank
@param RedBlackNode $node The subtree root

@return RedBlackNode
Retrieves the node with the key of a given rank in a subtree