void (@NotNull List<PatchAndVariants> candidates, @NotNull MultiMap<VirtualFile, AbstractFilePatchInProgress<?>> result) { for (Iterator<PatchAndVariants> iterator = candidates.iterator(); iterator.hasNext(); ) { final PatchAndVariants candidate = iterator.next(); if (candidate.getVariants().size() == 1) { final AbstractFilePatchInProgress oneCandidate = candidate.getVariants().get(0); result.putValue(oneCandidate.getBase(), oneCandidate); iterator.remove(); } else { final List<AbstractFilePatchInProgress> exact = new ArrayList<>(candidate.getVariants().size()); for (AbstractFilePatchInProgress patch : candidate.getVariants()) { if (patch.getCurrentStrip() == 0) { exact.add(patch); } } if (exact.size() == 1) { AbstractFilePatchInProgress<?> patchInProgress = exact.get(0); putSelected(result, candidate.getVariants(), patchInProgress); iterator.remove(); } else if (!exact.isEmpty()) { candidate.getVariants().retainAll(exact); } } } }