'Convert a MongoDB-compatible type to a Python type.'

def to_python(self, value):

    if ((not self.dbref) and (not isinstance(value, (DBRef, Document, EmbeddedDocument)))):
        collection = self.document_type._get_collection_name()
        value = DBRef(collection, self.document_type.id.to_python(value))
    return value
