 (defn find-merge-links [{:keys [causal-order branches] :as cg}]
   (let [branch-heads (into {} (map (fn [[k v]] [v k]) branches))]
     (assoc cg :merge-links
-      (->> causal-order
-           (filter-map [key val] (> (count val) 1))
+      (->> (select-keys causal-order
+                (for [[k v] causal-order
+                      :when (> (count v) 1)]
+                  k))
            (into {})
            (map (fn [[k v]] (map (fn [b] [b [(branches b) k]]) (remove nil? (map branch-heads v)))))
            (apply concat)

         (map
          (fn [[k v]]
            [k
             (map
              (fn [i]
                [(get v i) (get v (inc i))])
              (range (count v)))])))))

(comment


(ns signet.graph
  (:require [clojure.set :refer [difference]]
            [aprint.core :refer [aprint]]))


(defn branches->nodes [c causal-order heads]
