interface Diagnostic { val name: String } fun foo(conflicting: List) { val filtered = arrayListOf() conflicting.groupBy { it.name }.forEach { val diagnostics = it.value filtered.addAll( diagnostics.filter { me -> diagnostics.none { other -> me != other } } ) } }