                                                        (dissoc ancestors-map "category")
                                                        subfield value))
                                   parent-indexes)
-          ; ancestors-to-match (into {} (map (fn [[k v]]
-          ;                                    [(format "%s[%s][%s]"
-          ;                                             base-field
-          ;                                             (first parent-indexes)
-          ;                                             k)
-          ;                                     v])
-          ;                                  (dissoc ancestors-map "category")))
-          ; ancestors-found (into {} (for [[k v] ancestors-to-match
-          ;                                :when (= (str/lower-case v)
-          ;                                         (some-> (get query-params k) str/lower-case))]
-          ;                            [k v]))
           ancestors-found (map (fn [ancestor]
                                  (into {} (for [[k v] ancestor
                                                 :when (= (str/lower-case v)

      (if ancestors-found?
        (create-remove-link-for-hierarchical-field
         base-url query-params field-name ancestors-map parent-indexes value has-siblings?
         applied-children-tuples potential-qp-matches)
        (create-apply-link-for-hierarchical-field
         base-url query-params field-name ancestors-map parent-indexes value has-siblings?
         applied-children-tuples)))

                                    (map (fn [qp]
                                           (str/replace-first qp #"\]\[.*\]"
                                                              (format "][%s]" subfield))))
                                    (select-keys query-params))

          ;; TODO change to multiple indexes
          ; idx (some->> potential-qp-matches
          ;              keys
          ;              first
          ;              (re-find #"\[\d+\]")
          ;              second)
          ; _ (println "IDX=" idx)
          ; child-matches (when idx
          ;                 (concat (for [[k v] applied-children-tuples]
          ;                           [(format "%s[%s][%s]" base-field idx (csk/->snake_case_string k))
          ;                            v])))
          indexes (some->> potential-qp-matches
                           keys
                           (map #(re-find #"\[\d+\]" %))
                           (map second)
                           set)
          _ (println "IDX=" indexes)
          child-matches (mapcat
                          (fn [idx]
                            (concat (for [[k v] applied-children-tuples]
                                      [(format "%s[%s][%s]" base-field idx (csk/->snake_case_string k))
                                       v])))
                          indexes)]
        (println "Child matches are" child-matches)

        (println "potential-qp-matches are" potential-qp-matches)

      (if ancestors-found?
        (println "Found all ancestors!! for" field-name "and" value)
        (println "Did not find ancestors" ancestors-to-match ancestors-found))
