   delegator = utils.beget attributes
 
   # Add model to stack
-  if modelStack
-    modelStack.push model
-  else
-    modelStack = [model]
+  modelStack ?= {}
+  modelStack[model.cid] = true
 
   # Map model/collection to their attributes. Create a property
   # on the delegator that shadows the original attribute.

# in the context of a given tree
serializeModelAttributes = (model, currentModel, modelStack) ->
  # Nullify circular references
  return null if model is currentModel or model in modelStack
  # Serialize recursively
  attributes = if typeof model.getAttributes is 'function'
    # Chaplin models

        )
      delegator[key] = serializedModels

  # Remove model from stack.
  delete modelStack[model.cid]

  # Return the delegator
  delegator
