<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_field(self, key, field):
 """Add a field to the Payload. :API: public :param string key: The key for the field. Fields can be accessed using attribute access as well as `get_field` using `key`. :param PayloadField field: A PayloadField instance. None is an allowable value for `field`, in which case it will be skipped during hashing. """

    if key in self._fields:
      raise PayloadFieldAlreadyDefinedError(
        'Key {key} is already set on this payload. The existing field was {existing_field}.'
        ' Tried to set new field {field}.'
        .format(key=key, existing_field=self._fields[key], field=field))
    elif self._frozen:
      raise PayloadFrozenError(
        'Payload is frozen, field with key {key} cannot be added to it.'
        .format(key=key))
    else:
      self._fields[key] = field
      self._fingerprint_memo = None