 	value (first (.getExtant (.getData model)))]
     (.get (.getGetter #^Attribute (nth (.getAttributes (.getMetadata model)) 1)) value)))
 
+(defn to-list [#^Whale whale]
+  (map (fn [#^Attribute attribute] (.get (.getGetter attribute) whale)) (.getAttributes whale-metadata)))
+
 (defn flat-split-values [[metadata-fn data-fn]]
   (reduce
    (fn [values #^Result result]
        (println (.getModel result) (.getPrefix result) "," (.getPairs result) "," (.getOperation result))
-       (conj values [(map second (.getPairs result)) (.getExtant (.getData (.getModel result)))]))
+       (conj values [(map second (.getPairs result)) 
+		     (map to-list (.getExtant (.getData (.getModel result))))]))
    {}
    (.getExtant (.getData (.getModel (data-fn))))))
 

(defn nested-group-by [[fns-head & fns-tail] data]
  (reduce (fn [current [key val]] (conj current [key (if fns-tail (nested-group-by fns-tail val) val)])) {} (group-by (juxt fns-head) data)))

;;--------------------------------------------------------------------------------
;; tests


    [[key]
     (if (every? (fn [value] (instance? Result value)) values) ;TODO - is this the best I can do ?
       (reduce (fn [map value] (conj map (nested-split-values2 value))) {} values)
       (map to-list values))]))

(defn nested-split-values [[metadata-fn data-fn]]
    (second (nested-split-values2 (data-fn))))
