<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_task(self):
 """Return a task object representing this message."""

        from google.appengine.api.taskqueue import Task

        task_args = self.get_task_args().copy()

        payload = None
        if 'payload' in task_args:
            payload = task_args.pop('payload')

        kwargs = {
            'method': METHOD_TYPE,
            'payload': json.dumps(payload)
        }

        kwargs.update(task_args)

        return Task(**kwargs)