public function head() : Box
    {
        // keep track of visited boxes for cycle detection
        $touched = [];
        for ($b = $this; $b->prev !== null; $b = $b->visit($touched)->prev);
        return $b;
    }