private static int calcMinValueNeeded(int curActiveFrame,int minAValueNeeded,int minBValueNeeded, Map<PII, Integer> imActiveFrame, boolean optimizeA) {
		int minValueNeeded = (optimizeA ? minAValueNeeded : minBValueNeeded);
		for(Entry<PII, Integer> e : imActiveFrame.entrySet())
			if(curActiveFrame > e.getValue() && (optimizeA ? e.getKey().b >= minBValueNeeded : e.getKey().a >= minAValueNeeded))
				minValueNeeded = Math.max(minValueNeeded, (optimizeA ? e.getKey().a : e.getKey().b) + 1);
		return minValueNeeded;
	}