@classmethod
def get_or_create(cls, **fields):
    """Return an existing or create a new document.

        This will find and return a single document matching the
        query specified through ``**fields``. If no document is found,
        a new one will be created.

        Along with returning the ``Model`` instance, a boolean value
        will also be returned to indicate whether or not the document
        was created.

        :param safe: (optional) **DEPRECATED** Use ``w`` instead.
        :type safe: bool.
        :param w: (optional) The number of servers that must receive the
                  update for it to be successful.
        :type w: int.
        :param \\*\\*fields: Keyword arguments specifying the query.
        :type \\*\\*fields: \\*\\*kwargs.
        :returns: tuple -- the :class:`~simon.Model` and whether the
                  document was created.
        :raises: :class:`~simon.Model.MultipleDocumentsFound`

        """
    write_concern = {'safe': fields.pop('safe', None), 'w': fields.pop('w',
        None)}
    try:
        return cls.get(**fields), False
    except cls.NoDocumentFound:
        return cls.create(safe=write_concern['safe'], w=write_concern['w'],
            **fields), True
