long (Map<String, List<String>> strings) { long sum = 0L; for (Map.Entry<String, List<String>> s : strings.entrySet()) { if (!s.getKey().isEmpty()) { long count = count(s.getValue(), sx -> s.getKey().equals(sx)); sum += count; } } return sum; }