def to_dict(d, default=None):
    """
    Convert a ``dict`` or a ``list`` of pairs or single keys (or mixed) into a ``dict``.
    
    If a list element is single, `default` value is used.
    """
    if d is None:
        return {}
    if isinstance(d,dict):
        return d
    res={}
    for e in d:
        if isinstance(e,list) or isinstance(e,tuple):
            res[d[0]]=d[1]
        else:
            res[d[0]]=default
    return res