docs: @Pure
  	protected TypeReference getXFactoryFor(TypeReference type) {
  		final String packageName = type.getPackageName();
  		final Grammar grammar = getGrammar();
  		TypeReference reference = getXFactoryFor(packageName, grammar);
  		if (reference != null) {
  			return reference;
  		}
  
  		for (final Grammar usedGrammar : GrammarUtil.allUsedGrammars(grammar)) {
  			reference = getXFactoryFor(packageName, usedGrammar);
  			if (reference != null) {
  				return reference;
  			}
  		}
  		throw new IllegalStateException("Cannot find the XFactory for " + type); //$NON-NLS-1$
  	}