@classmethod
def one(cls, filter=None, **kwargs):
    """Return the first document matching the filter"""
    from mongoframes.queries import Condition, Group, to_refs
    kwargs['projection'], references, subs = cls._flatten_projection(kwargs
        .get('projection', cls._default_projection))
    if isinstance(filter, (Condition, Group)):
        filter = filter.to_dict()
    document = cls.get_collection().find_one(to_refs(filter), **kwargs)
    if not document:
        return
    if references:
        cls._dereference([document], references)
    if subs:
        cls._apply_sub_frames([document], subs)
    return cls(document)
