List<Location> (@NotNull List<Location> locations) { if (locations.size() < 2) { return locations; } MultiMap<Method, Location> byMethod = new MultiMap<>(); for (Location location : locations) { byMethod.putValue(location.method(), location); } List<Location> res = new ArrayList<>(); for (Map.Entry<Method, Collection<Location>> entry : byMethod.entrySet()) { res.addAll(removeMethodSameLineLocations(entry.getKey(), (List<Location>)entry.getValue())); } return res; }