code: def pymongo_class_wrapper(f, pymongo_class):
      
      @functools.wraps(f)
      @coroutine
      def _wrapper(self, *args, **kwargs):
          result = yield f(self, *args, **kwargs)
  
          # Don't call isinstance(), not checking subclasses.
          if result.__class__ == pymongo_class:
              # Delegate to the current object to wrap the result.
              raise gen.Return(self.wrap(result))
          else:
              raise gen.Return(result)
  
      return _wrapper
docs: Executes the coroutine f and wraps its result in a Motor class.
  
      See WrapAsync.