def _get_dict(obj):
    """
    Call __getstate__ or simply return __dict__.
    """
    if hasattr(obj, "__getstate__"):
        r = obj.__getstate__()
    else:
        r = obj.__dict__
    return r