Medusa\Tree\PersistentAvlTree::makeBalanced PHP Method

makeBalanced() private method

private makeBalanced ( Medusa\Tree\BinaryTree $t )
$t Medusa\Tree\BinaryTree
    private function makeBalanced(BinaryTree $t)
    {
        if ($this->isRightHeavy($t)) {
            if ($this->isLeftHeavy($t->right())) {
                return $this->doubleLeft($t);
            }
            return $this->rotateLeft($t);
        }
        if ($this->isLeftHeavy($t)) {
            if ($this->isRightHeavy($t->left())) {
                return $this->doubleRight($t);
            }
            return $this->rotateRight($t);
        }
        return $t;
    }