protected static function _tokenizePattern($pattern, $delimiter, &$variable = null)
    {
        $tokens = [];
        $index = 0;
        $path = '';
        $parts = static::split($pattern);

        foreach ($parts as $part) {
            if (is_string($part)) {
                $tokens = array_merge($tokens, static::_tokenizeSegment($part, $delimiter, $variable));
                continue;
            }

            $greedy = $part[1];
            $repeat = $greedy === '+' || $greedy === '*';
            $optional = $greedy === '?' || $greedy === '*';

            $children = static::_tokenizePattern($part[0], $delimiter, $variable);

            $tokens[] = [
                'optional' => $optional,
                'greedy'   => $greedy ?: '?',
                'repeat'   => $repeat ? $variable : false,
                'pattern'  => $part[0],
                'tokens'   => $children
            ];

        }
        return $tokens;
    }