- val identitiesWithTrust = values.flatten()
- .groupBy { it.id }
- .mapValues { (_, identities) ->
- identities.reduce { accIdentity, identity ->
- identity.trust.forEach { (ownIdentity: OwnIdentity?, trust: Trust?) ->
- accIdentity.setTrust(ownIdentity, trust)
- }
- accIdentity
- }
- }
-
- mapValues { (_, trustedIdentities) ->
- trustedIdentities.filter { trustedIdentity ->
- identitiesWithTrust[trustedIdentity.id]!!.trust.all { it.value.hasZeroOrPositiveTrust() }
- }
- }