Consider replacing the mutable set by a `fold` over `needsBridges` / `neededBridges`.