def METHOD_NAME(self, obj):
    """
    This is the public conversion method.  It will be applied to dictionary
    values, list items, and the object itself, applying the to_dict functions
    of any registered type to the objects, or return the object unchanged if
    it is not recognized.
    :param obj: the object to be converter
    Returns:
        the dictionary representation for registered objects or the original
        for unregistered objects
    """
    typename = self.typenames.get(obj.__class__)
    if typename in self.convert_to_dict:
        to_dict = self.convert_to_dict.get(typename)
        return to_dict(obj)
    elif isinstance(obj, dict):
        return dict((k, self.METHOD_NAME(v)) for k, v in obj.items())
    elif isinstance(obj, (list, tuple, set)):
        return obj.__class__([ self.METHOD_NAME(item) for item in obj ])
    else:
        return obj