void (final String filter) { final Collection<RepoPackage> toProcess = toProcess(); toProcess.addAll(myFilteredOut); myFilteredOut.clear(); final ArrayList<RepoPackage> filtered = new ArrayList<>(); RepoPackage toSelect = null; for (RepoPackage repoPackage : toProcess) { final String packageName = repoPackage.getName(); if (StringUtil.containsIgnoreCase(packageName, filter)) { filtered.add(repoPackage); } else { myFilteredOut.add(repoPackage); } if (StringUtil.equalsIgnoreCase(packageName, filter)) toSelect = repoPackage; } filter(filtered, toSelect); }