def _unicode_to_string(self, data):
    if isinstance(data, basestring):
        return str(data)
    elif isinstance(data, Mapping):
        return dict(map(self._unicode_to_string, data.iteritems()))
    elif isinstance(data, Iterable):
        return type(data)(map(self._unicode_to_string, data))
    else:
        return data
def _unicode_to_string(self, data):
    if isinstance(data, basestring):
        return str(data)
    elif isinstance(data, Mapping):
        return dict(map(self._unicode_to_string, data.iteritems()))
    elif isinstance(data, Iterable):
        return type(data)(map(self._unicode_to_string, data))
    else:
        return data