private static void optimizeMoves(List<DefinedMove> path) {
		DefinedMove prevMove = null;
		int count = 1;
		for (ListIterator<DefinedMove> it = path.listIterator(); it.hasNext(); ) {
			DefinedMove move = it.next();
			
			/*
			 * Check if some move is repeated 3 times
			 */
			if (move.equals(prevMove))
				count++;
			else
				count = 1;
			
			if (count == 3) {
				// We remove current move
				it.remove();
				
				// Then we remove the 2 previous one
				it.previous();
				it.remove();
				it.previous();
				it.remove();
				
				if (RubiksCube2D.DEBUG)
					System.out.println("AI : we should replace last three " + move + " with a " + Move.inverse(move.getMove()) + "@" + move.getFaceIndex());
				
				// Finally we replace with the inverse move
				move = new DefinedMove(Move.inverse(move.getMove()), move.getFaceIndex());
				it.add(move);
				
				// We reinit the previous correctly then we reset the iterator at the current position
				prevMove = it.previous();
				it.next();
				
				count = 1;
			}
			
			/*
			 * Check if some move is followed by its opposite
			 */
			if (prevMove != null && move.equals(new DefinedMove(Move.inverse(prevMove.getMove()), prevMove.getFaceIndex()))) {
				it.remove();
				it.previous();
				it.remove();
				
				if (RubiksCube2D.DEBUG)
					System.out.println("AI : we should remove last " + move + " and its previous inverse " + prevMove);
			}
				
			prevMove = move;
		}
	}