public boolean detectAmbiguities() {
		iteration = 0;
		int maxpairs = 0;
		int prevSize;
		int size = nfa.items.size() + 2 + nfa.transitions.size();
		
		do {
			++iteration;
			
			monitor.println("\nBuilding pair graph:");
			if (!traverse()) {
				// aborted by user
				return false;
			}			
			monitor.println(done.usageStatistics());

			if (maxpairs == 0 ) {
				maxpairs = done.size();
			}
	
			if (AmbiDexterConfig.outputGraphs) {
				toDot(nfa.grammar.name + ".pp" + iteration + ".dot");
			}
			if (AmbiDexterConfig.outputDistMap) {
				computeDistanceMap(nfa.grammar.name + ".distmap" + iteration + ".png");
				//computeUsageMap(nfa.grammar.name + ".pairmap" + iterations + ".png");
			}
			
			filter();
			nfa.printSize("\nNFA " + iteration, monitor);
			monitor.println("Used productions: " + nfa.getUsedProductions().size());
			
			if (AmbiDexterConfig.outputGraphs) {
				nfa.toDot(nfa.grammar.name + ".nfa" + iteration + ".dot");
			}
			
			prevSize = size;
			size = nfa.items.size() + 2 + nfa.transitions.size();
		} while (size > 3 && size != prevSize); // 3 are always used: startstate, endstate, and shift between the two
		
		monitor.println("\nIterations: " + iteration + ", max pairs: " + maxpairs);
		return true;
	}