def compare_list_of_committees(committees1, committees2):
    """
    Check whether two lists of committees are equal.

    The order of candidates and their multiplicities in these lists are ignored.
    To be precise, two lists are equal if every committee in list1 is contained in list2 and
    vice versa.
    Committees are, as usual, of type `CandidateSet` (i.e., sets of positive integers).

    .. doctest::

        >>> comm1 = CandidateSet({0, 1, 3})
        >>> comm2 = CandidateSet({0, 3, 1})  # the same set as `comm1`
        >>> comm3 = CandidateSet({0, 1, 4})
        >>> compare_list_of_committees([comm1, comm2, comm3], [comm1, comm3])
        True
        >>> compare_list_of_committees([comm1, comm3], [comm1])
        False

    Parameters
    ----------
        committees1, committees2 : list of CandidateSet
            Two lists of committees.

    Returns
    -------
        bool
    """
    for committee in committees1 + committees2:
        if not isinstance(committee, set):
            raise ValueError("Input has to be two lists of sets.")
    return all(committee in committees1 for committee in committees2) and all(
        committee in committees2 for committee in committees1
    )