   (let [attributes (:attributes feature)
         nested (nested-features attributes)
         attributes-without-nested (apply dissoc attributes (map #(first %) nested))
-        enriched-nested (map #(enrich % feature attributes-without-nested) nested)]
+        enriched-nested (map #(enrich % feature attributes-without-nested) nested)
+        close-all (meta-close-all-features enriched-nested)]
     (if (empty? enriched-nested)
       (assoc feature :action :drop)
-      enriched-nested))
+      (concat close-all enriched-nested)))
   )
 
 (defn- flatten [feature]

                     (assoc! :dataset dataset)
                     (assoc! :parent-collection collection)
                     (assoc! :parent-id id)
                     (assoc! :collection (str collection "$" child-collection-key))
                     (assoc! :action action)
                     (assoc! :id child-id)
                     (assoc! :validity validity)
                     (assoc! :attributes (merge (:attributes child) parent-attributes)))]
   (persistent! enriched) ))

(defn- flatten-with-geometry [feature]
  (let [attributes (:attributes feature)
        nested (nested-features attributes)
        without-nested (apply dissoc attributes (map #(first %) nested))
        flat (assoc feature :attributes without-nested)
        linked-nested (map #(link-parent % feature) nested)]
    (if (empty? linked-nested)
      flat
      (cons flat linked-nested))
    )
  )


                  (assoc! :dataset dataset)
                  (assoc! :parent-collection collection)
                  (assoc! :parent-id id)
                  (assoc! :action :new)
                  (assoc! :id child-id)
                  (assoc! :validity validity)
                  (assoc! :collection (str collection "$" (name child-collection-key))))]
