Then make NonTerminal have a boolean flag "userDefined" and hide NonTerminals based on that information. That will at the very least remove 2 of the 3 places that getNonTerminalCallers is called from, which would make your argument about caching a good one. So pick whichever change you want and go with it, but you need to do one of them.