import collections


def get_sub_combinations(maxop):
    """Return a dictionary of lists of combinations suitable
       for recursively building expressions.

       Each dictionary key is a tuple of (numops, numoperands),
       where:

            numops is the number of operators we
            should build an expression for

            numterms is the number of operands required
            by the current operator.

        Each list contains all permutations of the number
        of operators that the recursively called function
        should use for each operand.
    """
    combo = collections.defaultdict(list)
    for numops in range(maxop+1):
        if numops:
            combo[numops, 1].append((numops-1,))
        for op1 in range(numops):
            combo[numops, 2].append((op1, numops - op1 - 1))
            for op2 in range(numops - op1):
                combo[numops, 3].append((op1, op2, numops - op1 - op2 - 1))
    return combo