               callback err
               fin()
             else
-                wantedOrder = []
-                collections = {}
                 if relatedResult.reply?
-                  for obj in relatedResult.reply
-                    collections[obj.name] ||= []
-                    collections[obj.name].push(obj.id)
-                    wantedOrder.push({id: obj.id, collection: obj.name, idx: obj.id+'_'+obj.name})
+                  {collections, wantedOrder} = @getIdsFromAResultSet relatedResult.reply
                   @fetchObjectsFromMongo collections, wantedOrder, (err, dbObjects)->
-                    for dbObj in dbObjects
-                      res.replies.push dbObj
+                    res.replies.push dbObj for dbObj in dbObjects
                     tempRes.push res
                     fin()
                 else

            callback null, tempRes

        resultData = []
        wantedOrder = []
        collections = {}
        for result in results
          obj = result.content.data
          collections[obj.name] ||= []
          collections[obj.name].push(obj.id)
          wantedOrder.push({id: obj.id, collection: obj.name, idx: obj.id+'_'+obj.name})
        @fetchObjectsFromMongo collections, wantedOrder, (err, dbObjects)->
          for dbObj in dbObjects
            collectRelations dbObj
          #callback err, dbObjects


  objectify = (incomingObjects, callback)->

_ = require 'underscore'
neo4j = require "neo4j"
{race} = require 'sinkrow'
{Base, ObjectId, race} = require 'bongo'
