                                     :content-type content-type})))))))
 
 
+(defn trace-parent
+  "Compute ancestor trace of given tweet"
+  [tweet origins]
+  (let [replied-id (:in_reply_to_status_id_str tweet)
+        retweeted-status-id (-> tweet :retweeted_status :id_str)
+        parent (if replied-id
+                 (mc/find-one-as-map (:db @mongo-state) "tweets" {:id_str replied-id})
+                 (if retweeted-status-id
+                   (mc/find-one-as-map (:db @mongo-state) "tweets" {:id_str retweeted-status-id})
+                   nil))]
+    (if parent
+      (trace-parent parent (into origins [(:_id parent)]))
+      origins)))
+
+
 (defn store-url [{:keys [article record ts source]}]
   (mc/insert-and-return
    (:db @mongo-state)

       clojure.pprint/pprint)



  (->> (mc/find-maps (:db @mongo-state) "urls" {:article (first sz-url)})
       (mapv #(assoc % :tweet  (mc/find-map-by-id (:db @mongo-state) "tweets" (:tweet %) [:in_reply_to_status_id_str :text :user.screen_name :retweeted :id_str])))
       clojure.pprint/pprint)

  (def spon-url (->> (mc/find-maps (:db @mongo-state) "articles" {:ts {$gt (t/today)}} [:title])
                  (map #(vec [(:_id %) (:title %) (first (find-source (:_id %)))]))
                  (remove #(empty? (last %)))
                  (filter #(= "SPIEGELONLINE" (-> % last :source)))

   {:tweet record
    :article article
    :source source
    :ts ts}))


(defn store-origin [{:keys [article record ts source ancestors]}]
  (mc/insert-and-return
   (:db @mongo-state)
   "origins"
   {:tweet record
    :article article
    :source source
    :ancestors ancestors
    :ts ts}))


