private static function findNextOpt(Variable $var)
    {
        $nextIsOpt = true;

        $next = null;
        $n = $var->next;

        while (null !== $n) {
            if (!$n instanceof Variable) {
                $n = $n->next;
                $nextIsOpt = true;
                continue;
            }
            if (!$n->required) {
                $nextIsOpt = true;
                $next = $n;
                break;
            }

            $nextIsOpt = false;
            $n = $n->next;
        }

        return [$next, $nextIsOpt];
    }