'Converts this protocol unit into a :py:class:`dict`, ready to be
encoded as JSON.
The keys it encodes are: `valid_keys` - `internal_keys`
Returns
dict'

def get_dict(self):

    d = {k: _encode(v) for (k, v) in self.__dict__.items() if ((k in self.valid_keys) and (k not in self.internal_keys))}
    d.update(self.unrecognized_keys)
    return d
