List<String> (List<String> roots, List<? super String> ignored) { List<String> filtered = null; for (int i = 0; i < roots.size(); i++) { String root = roots.get(i); if (OSAgnosticPathUtil.isUncPath(root)) { if (filtered == null) { filtered = new ArrayList<>(roots.subList(0, i)); } ignored.add(root); } else if (filtered != null) { filtered.add(root); } } return filtered != null ? filtered : roots; }