public function entangle(Box $b) : Box
    {
        $root1 = $this->find();
        $root2 = $b->find();

        // if already in same set then nothing to do
        if ($root1 === $root2) {
            return $this;
        }

        // union by rank
        if ($root1->rank > $root2->rank) {
            $root2->parent = $root1;
        } elseif ($root2->rank > $root1->rank) {
            $root1->parent = $root2;
        } else {
            $root2->parent = $root1;
            ++$root1->rank;
        }

        // merge circular linked lists
        $tmp = $this->child;
        $this->child = $b->child;
        $b->child = $tmp;

        return $this;
    }