code: def to_utf8(self, data):
          
          # if this is a unicode string, return its string representation
          if isinstance(data, unicode):
              return data.encode('utf-8')
  
          # if this is a list of values, return list of string values
          if isinstance(data, list):
              return [self.to_utf8(item) for item in data]
  
          # if this is a dictionary, return dictionary of string keys and values
          if isinstance(data, dict):
              return {
                  self.to_utf8(key): self.to_utf8(value)
                  for key, value in data.iteritems()
              }
  
          # if it's anything else, return it in its original form
          return data
docs: Convert unicode values to strings even if they belong to lists or dicts.
          :param data: an object.
          :return: The object with all unicode values converted to string.