private void detectCyclesVisit(Terminal u,
			                     Stack<Terminal> stackU,
			                     int[] colors,
			                     CompilerLogger logger,
			                     String location,
			                     Queue<Terminal> topologicallySortedVertices)
	throws CopperException
	{
		stackU.push(u);
		colors[getVertexNumber(u)] = FringeSymbols.GRAY;
		for(Terminal v : vertices.keySet())
		{
			if(!hasEdge(u,v)) continue;
			if(colors[getVertexNumber(v)] == FringeSymbols.WHITE) detectCyclesVisit(v,stackU,colors,logger,location,topologicallySortedVertices);
			else if(colors[getVertexNumber(v)] == FringeSymbols.GRAY)
			{
				if(logger.isLoggable(CompilerLogMessageSort.ERROR))
				{
					ArrayList<String> cycleMembers = new ArrayList<String>();
					int startIndex = stackU.lastIndexOf(v);
					if(startIndex != -1)
					{
						for(int i = startIndex;i < stackU.size();i++) cycleMembers.add(stackU.get(i).toString());
					}
					logger.logErrorMessage(CompilerLogMessageSort.ERROR,null,"In " + location + ":\nCyclic precedence relation involving terminals\n" + PrettyPrinter.iterablePrettyPrint(cycleMembers,"  ",1) + " on graph\n" + this);
				}
			}
		}
		colors[getVertexNumber(u)] = FringeSymbols.BLACK;
		if(topologicallySortedVertices != null) topologicallySortedVertices.offer(u);
		stackU.pop();
	}