       [this parent]
       [this])
 
-    ;; For a DateTimeField we'll flatten it back into regular Field but include the :unit info for the frontend
-    metabase.driver.query_processor.interface.DateTimeField
-    (recur (assoc (:field this) :unit (:unit this)))
+    clojure.lang.IPersistentMap
+    (for [[k v] (seq this)
+          field (collect-fields v)
+          :when field]
+      (update field :path conj k))
+
+    clojure.lang.Sequential
+    (mapcat collect-fields this)
 
     nil))
 
 (defn- flatten-fields
   "Flatten a group of fields, keeping those which are more important when duplicates exist."
   [fields]
+  {:pre [(every? identity fields)]}
   (let [path-importance (fn [{[k] :path}]
                           (cond
                             (= k :breakout) 0     ; lower number = higher importance, because `sort` is ascending

     (collect-fields {:a {:name \"id\", ...}) -> [{:name \"id\", :path [:a], ...}]"
  [this]
  (condp instance? this
    clojure.lang.IPersistentMap
    (for [[k v] (seq this)
          field (collect-fields v)]
      (update field :path conj k))

    clojure.lang.Sequential
    (mapcat collect-fields this)

    metabase.driver.query_processor.interface.Field
    (if-let [{:keys [parent]} this]
      ;; Nested Mongo fields come back inside of their parent when you specify them in the fields clause
      ;; e.g. (Q fields venue...name) will return rows like {:venue {:name "Kyle's Low-Carb Grill"}}
      ;; Until we fix this the right way we'll just include the parent Field in the :query-fields list so the pattern

  (assoc field :field-name (keyword (apply str (->> (rest (i/qualified-name-components field))
                                                    (interpose "."))))))

(defn collect-fields
  "Return a sequence of all the `Fields` inside THIS, recursing as needed for collections.
   For maps, add or `conj` to property `:path`, recording the keypath used to reach each `Field.`

