Medusa\Tree\PersistentRedBlackTree::balance PHP Метод

balance() приватный Метод

private balance ( Medusa\Tree\RedBlackTree $t )
$t Medusa\Tree\RedBlackTree
    private function balance(RedBlackTree $t)
    {
        if ($this->isRed($t->right())) {
            $t = $this->rotateLeft($t);
        }
        if ($this->isRed($t->left()) && $this->isRed($t->left()->left())) {
            $t = $this->rotateRight($t);
        }
        if ($this->isRed($t->left()) && $this->isRed($t->right())) {
            $t = $this->flipColors($t);
        }
        return $t;
    }