protected ATNConfigSet removeAllConfigsNotInRuleStopState(ATNConfigSet configs, boolean lookToEndOfRule) {
		if (PredictionMode.allConfigsInRuleStopStates(configs)) {
			return configs;
		}

		ATNConfigSet result = new ATNConfigSet(configs.fullCtx);
		for (ATNConfig config : configs) {
			if (config.state instanceof RuleStopState) {
				result.add(config, mergeCache);
				continue;
			}

			if (lookToEndOfRule && config.state.onlyHasEpsilonTransitions()) {
				IntervalSet nextTokens = atn.nextTokens(config.state);
				if (nextTokens.contains(Token.EPSILON)) {
					ATNState endOfRuleState = atn.ruleToStopState[config.state.ruleIndex];
					result.add(new ATNConfig(config, endOfRuleState), mergeCache);
				}
			}
		}

		return result;
	}
Return a configuration set containing only the configurations from
{@code configs} which are in a {@link RuleStopState}. If all
configurations in {@code configs} are already in a rule stop state, this
method simply returns {@code configs}.

<p>When {@code lookToEndOfRule} is true, this method uses
{@link ATN#nextTokens} for each configuration in {@code configs} which is
not already in a rule stop state to see if a rule stop state is reachable
from the configuration via epsilon-only transitions.</p>

@param configs the configuration set to update
@param lookToEndOfRule when true, this method checks for rule stop states
reachable by epsilon-only transitions from each configuration in
{@code configs}.

@return {@code configs} if all configurations in {@code configs} are in a
rule stop state, otherwise return a new configuration set containing only
the configurations from {@code configs} which are in a rule stop state
runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java