     (omp/queue! reconciler data-path-keys)
     @state))
 
+(defn- merge-alternate-union-elements! [app root-component]
+  (letfn [(walk-ast
+            ([ast visitor]
+             (walk-ast ast visitor nil))
+            ([ast visitor last-join-component]
+             (visitor ast last-join-component)
+             (when (:children ast)
+               (let [join-component (if (= :join (:type ast))
+                                      (:component ast)
+                                      last-join-component)]
+                 (doseq [c (:children ast)]
+                   (walk-ast c visitor join-component))))))
+          (merge-union [{:keys [type component query children] :as n} last-join-component]
+            (when (= :union type)
+              (let [default-branch (and last-join-component (implements? InitialAppState last-join-component) (initial-state last-join-component nil))
+                    to-many? (vector? default-branch)]
+                (doseq [element (->> query vals (map (comp :component meta)))]
+                  (let [state (and (implements? InitialAppState element) (initial-state element nil))]
+                    (cond
+                      (and state (not default-branch)) (log/warn "Subelements of union with query " query " have initial state, but the union component itself has no initial app state. Your app state may not have been initialized correctly.")
+                      (not to-many?) (merge-state! app last-join-component state)))))))]
+    (walk-ast
+      (om/query->ast (om/get-query root-component))
+      merge-union)))

        (do
          (when (and (or (= Atom (type initial-state)) (seq initial-state)) (implements? InitialAppState root-component))
            (log/warn "You supplied an initial state AND a root component with a constructor. Using InitialAppState!"))
          (app/initialize this state root-component dom-id-or-node reconciler-options)))))

  (reset-state! [this new-state] (reset! (om/app-state reconciler) new-state))


   If the target is a vector element then that element must already exist in the vector.
  "
  [state ident & named-parameters]
  (let [already-has-ident-at-path? (fn [data-path] (boolean (seq (filter #(= % ident) (get-in @state data-path)))))
        actions (partition 2 named-parameters)]
    (doseq [[command data-path] actions]
      (case command
        :prepend (when-not (already-has-ident-at-path? data-path)
                   (assert (vector? (get-in @state data-path)) (str "Path " data-path " for prepend must target an app-state vector."))
