     #(= data-type (:data/type %))
     #(= (count (::children %))
         (inc (count (::keys %))))))
+
+
+
+;; ## Branching Factor
+
+(def default-branching-factor
+  "The default number of children to limit each index node to."
+  256)
+
+
+(defn max-branches
+  "Return the maximum number of children a valid index node can have given the
+  parameters."
+  [params]
+  (::branching-factor params default-branching-factor))
+
+
+(defn min-branches
+  "Return the minimum number of children a valid index node must have given the
+  parameters."
+  [params]
+  (int (Math/ceil (/ (max-branches params) 2))))
 
 
 

         height 1]
    (if (<= (count layer) 1)
      (first layer)
      (let [index-groups (part/partition-limited
                           (::branching-factor params default-branching-factor)
                           layer)]
        (recur (mapv (fn store-index
                       [children]
                       (->> (index-children height children)

          ; Result elements are a carry.
          :else
            (recur outputs result (next inputs))))
      ; No more input nodes.
      (if (seq outputs)
        (let [outputs (if carry
