/**
* Gather all the alternatives ending with the given child.
*/
protected void gatherAlternatives(INodeFlattener<T, S> converter, INodeConstructorFactory<T, S> nodeConstructorFactory, Link child, ArrayList<T> gatheredAlternatives, Object production, IndexedStack<AbstractNode> stack, int depth, CycleMark cycleMark, HashMap<ArrayList<Link>, SharedPrefix<T>> sharedPrefixCache, PositionStore positionStore, int offset, int endOffset, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object environment){
AbstractNode childNode = child.getNode();
if(!(childNode.isEpsilon() && child.getPrefixes() == null)){ // Has non-epsilon results.
ArrayList<AbstractNode> blackList = new ArrayList<AbstractNode>();
if(childNode.isEmpty()){ // Child starts a cycle.
CycleNode cycle = gatherCycle(child, new AbstractNode[]{childNode}, blackList);
if(cycle != null){ // Encountered a cycle.
if(cycle.cycle.length == 1){
gatherProduction(converter, nodeConstructorFactory, child, new ForwardLink<AbstractNode>(NO_NODES, cycle), gatheredAlternatives, production, stack, depth, cycleMark, sharedPrefixCache, positionStore, blackList, offset, endOffset, filteringTracker, actionExecutor, environment);
}else{