Because you can iterate Option in a for-comprehension, you can change "=" to "<-" and this will give you the same result as flatten
val firstCauses : Set[Cause] = (for {
effect <- effects
possibleCause <- allCauses.find(_.possibleEffects.contains(effect))
} yield possibleCause)