protected Pair<FrequencySet<String>, FrequencySet<String>> getElementFrequenciesForAlt(AltAST ast) {
		try {
			ElementFrequenciesVisitor visitor = new ElementFrequenciesVisitor(new CommonTreeNodeStream(new GrammarASTAdaptor(), ast));
			visitor.outerAlternative();
			if (visitor.frequencies.size() != 1) {
				factory.getGrammar().tool.errMgr.toolError(ErrorType.INTERNAL_ERROR);
				return new Pair<>(new FrequencySet<String>(), new FrequencySet<String>());
			}

			return new Pair<>(visitor.getMinFrequencies(), visitor.frequencies.peek());
		}
		catch (RecognitionException ex) {
			factory.getGrammar().tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, ex);
			return new Pair<>(new FrequencySet<String>(), new FrequencySet<String>());
		}
	}
Given list of X and r refs in alt, compute how many of each there are
tool/src/org/antlr/v4/codegen/model/RuleFunction.java