def attrs_as_dict(obj):
    """
    Tries different methods to get a dict representation of obj.
    """

    attrs = None

    if hasattr(obj, "__getstate__"):
        attrs = obj.__getstate__()
    elif hasattr(obj, "__dict__"):
        attrs = obj.__dict__
    elif hasattr(obj, "__slots__"):
        attr_dict = {n: getattr(obj, n) for n in obj.__slots__}
    elif isinstance(obj, dict):
        attrs = obj

    return attrs