import copy


def all_possible_answers(list_of_questions):
    """Given a sequence of IQuestions, return a list of answer dictionaries.
       These are meant to be used with LicenseSelector.by_answers. This
       function will generate a set of answer dictionaries that embody
       every possible permutation of the answers to the questions given."""
    questions = copy.deepcopy(list_of_questions)
    answer_dict_list = []
    answer_dict_list.append({}) # seed

    def recursive_build_answers(adl, qs):
        if len(qs) == 0:
            return adl
        q = qs.pop()
        new_adl = []
        for adict in adl:
            for enum in q.answers():
                answer = enum[1] # the answer value 
                aclone = adict.copy()
                aclone[q.id] = answer
                new_adl.append(aclone)
        return recursive_build_answers(new_adl, qs)

    return recursive_build_answers(answer_dict_list, questions)