       :post [(group? %)]}
      (Group. contexts examples subgroups nil metadata)))
 
+(defn separate-examples-subgroups
+  "Separates examples from subgroups in collection, after flattening.
+  Returns a vector like [examples subgroups]."
+  [coll]
+  (let [parts (flatten coll)]
+    [(vec (remove group? parts)) (vec (filter group? parts))]))
+
+(defn group-from-children
+  "Like new-group but automatically separates examples from subgroups
+  in children."
+  [contexts children metadata]
+  (let [[examples subgroups] (separate-examples-subgroups children)]
+    (new-group contexts examples subgroups metadata)))
+
 (defmacro example
   "Creates an example function, using current context locals for
   arguments, with expr as its body."


;; group
(let [c1 (com.stuartsierra.lazytest.contexts/context [] 1)
      g (group [x c1] (group-examples (= 1 x) "foo" (= x 2)) [])]
  (assert (group? g))
  (assert (= [c1] (:contexts g)))
  (let [exs (:examples g)]

        givens (interleave (firsts (:given opts))
                           (map (fn [e] `(context [] ~e))
                                (seconds (:given opts))))
        bindings (vec (concat (:using opts) givens))]
    `(with-meta (group ~bindings (vector ~@body))
       ~(standard-metadata &form docstring))))

;;; Assertions
