fromBranch :: Applicative m => Branch m -> (Branches m, Dependencies)
fromBranch (Branch c) = case c of
  Causal.One _hh e         -> fromBranch0 e
  Causal.Cons _hh e (h, m) -> fromBranch0 e <> fromTails (Map.singleton h m)
  Causal.Merge _hh e tails -> fromBranch0 e <> fromTails tails
  where
  fromTails m = ([(h, Just (Branch <$> mc)) | (h, mc) <- Map.toList m], mempty)
fromBranch :: Applicative m => Branch m -> (Branches m, Dependencies)
fromBranch (Branch c) = case c of
  Causal.One _hh e         -> fromBranch0 e
  Causal.Cons _hh e (h, m) -> fromBranch0 e <> fromTails (Map.singleton h m)
  Causal.Merge _hh e tails -> fromBranch0 e <> fromTails tails
  where
  fromTails m = ([(h, Just (Branch <$> mc)) | (h, mc) <- Map.toList m], mempty)
fromBranch (Branch c) = case c of
  Causal.One _hh e         -> fromBranch0 e
  Causal.Cons _hh e (h, m) -> fromBranch0 e <> fromTails (Map.singleton h m)
  Causal.Merge _hh e tails -> fromBranch0 e <> fromTails tails
  where
  fromTails m = ([(h, Just (Branch <$> mc)) | (h, mc) <- Map.toList m], mempty)