protected function getGroupNodeClosingIndex(array $expression)
    {
        $parenthesis = 1;
        $index = 0;

        while ($parenthesis > 0) {
            $index++;
            if ($index > count($expression)) {
                $this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND);
            }

            if ('(' === $expression[$index]) {
                $parenthesis++;
            } elseif (')' === $expression[$index]) {
                $parenthesis--;
            }
        }

        return $index;
    }