private function compileRouteTree(PHPCodeCollection $code, array $routeTree): void
    {
        $code->appendLine('switch (count($segments)) {');

        $code->indent++;

        foreach ($routeTree[1] as $segmentDepth => $nodes) {
            $code->appendLine('case ' . $segmentDepth . ':');

            $code->indent++;

            $segmentVariables = [];

            for ($i = 0; $i < $segmentDepth; $i++) {
                $segmentVariables[$i] = '$s' . $i;
            }

            $code->appendLine('[' . \implode(', ', $segmentVariables) . '] = $segments;');

            $this->compileSegmentNodes($code, $nodes, $segmentVariables);
            $this->compileDisallowedHttpMethodOrNotFound($code);

            $code->appendLine('break;');

            $code->indent--;

            $code->appendLine();
        }

        $code->appendLine('default:');

        $code->indent++;

        $this->compileNotFound($code);

        $code->indent--;
        $code->indent--;

        $code->append('}');
    }