public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int enterCounter = matchResult.GetEnterCounter(setCounter);

            if (!innerSet.HasConsumed(matchResult))
            {
                return(next.Matches(stringIndex, testString, matchResult));
            }

            // can't go inner set;
            if (enterCounter >= quantifier.Max())
            {
                matchResult.SetEnterCounter(setCounter, 0);
                return(next.Matches(stringIndex, testString, matchResult));
            }

            int nextIndex;

            if (enterCounter >= quantifier.Min())
            {
                nextIndex = next.Matches(stringIndex, testString, matchResult);
                if (nextIndex < 0)
                {
                    matchResult.SetEnterCounter(setCounter, ++enterCounter);
                    nextIndex = innerSet.Matches(stringIndex, testString,
                                                 matchResult);
                }
                else
                {
                    matchResult.SetEnterCounter(setCounter, 0);
                    return(nextIndex);
                }
            }
            else
            {
                matchResult.SetEnterCounter(setCounter, ++enterCounter);
                nextIndex = innerSet.Matches(stringIndex, testString, matchResult);
            }

            return(nextIndex);
        }