def attrs_to_dict(attrs):
    """
        Convert a list of tuples of (name, value) attributes to a single dict of attributes [name] -> value
    :param attrs: List of attribute tuples
    :return: Dict of attributes
    """
    out = {}
    for attr in attrs:
        if out.get(attr[0]) is None:
            out[attr[0]] = attr[1]
        else:
            if not isinstance(out[attr[0]], list):
                out[attr[0]] = [out[attr[0]]]
            out[attr[0]].append(attr[1])
    return out