def powerset(a):
    """
    Return the set of all subsets of a.
    """
    if len(a) == 0:
        return set([frozenset()])
    accumulator = set()
    a = set(a)
    element = a.pop()
    for subset in powerset(a):
        accumulator.add(subset)
        accumulator.add(frozenset(set([element]) | subset))
    return accumulator