   (let [parent-team-map (->> (get-in node [:data :teams])
                              (map #((juxt :name identity) %))
                              (into {}))]
-    (if (and (get node :upper) (get node :lower))
+    (if (branch? node)
       (-> (update-in node [:upper] (partial update-child-expected-value parent-team-map))
           (update-in [:lower] (partial update-child-expected-value parent-team-map)))
       node)))

    treeify
    bracket))

(defn- compute-round-dispatch [_ node]
  (when (and (map? node) (contains? node :upper) (contains? node :lower))
    (if (get-in node [:data :round])
      :branch
      :root)))

(defmulti #^{:private true} compute-round
          compute-round-dispatch)
(defmethod compute-round :default [_ node]
  node)
(defmethod compute-round :branch [_ node]
  (let [current-round (get-in node [:data :round])]
    (-> (assoc-in node [:upper :data :round] (dec current-round))
        (assoc-in [:lower :data :round] (dec current-round)))))
(defmethod compute-round :root [max-rounds node]
  (compute-round max-rounds (assoc-in node [:data :round] max-rounds)))

(defn round-info [max-rounds tree]
  (walk/prewalk
    (partial compute-round max-rounds)
    tree))

(defn weighted-pairing-log5
  "Compute and update the chance that Team a and Team b will advance when playing against each other,

  (if (zip/end? loc)
    loc
    (recur (zip/next (zip/edit loc update-expected-value)))))

(defn compute-expected-value
  "Compute the expected value for each node in the tournament probabilites tree."
