def _getstate(self, obj, data):
    state = self._flatten(obj)
    if self.unpicklable:
        data[tags.STATE] = state
    else:
        data = state
    return data
def _getstate(self, obj, data):
    state = self._flatten(obj)
    if self.unpicklable:
        data[tags.STATE] = state
    else:
        data = state
    return data