 
   collection
 
+loopMax = (f) ->
+  for i in [0..MAX_RETRIES]
+    throw "Possible infinite loop" if i is MAX_RETRIES
+    break unless f()
+
 class globals.Document
   # TODO: When we will require all fields to be specified and have validator support to validate new objects, we can also run validation here and check all data, reference fields and others
   @objectify: (parent, ancestorArray, obj, fields) ->

    @documents = new @_Manager @Meta

    @_addDelayed @
    @_retryDelayed()

  @list = []
  @_delayed = []

    for document in delayed
      delete document.Meta._delayIndex

    processedCount = 0

    for document in delayed
      assert not document.Meta._listIndex?

