def generateListPermutations(elements, level=0):
    """Generate all possible permutations of the list 'elements'."""
    #print("  " * level, "gP(", elements, ")")
    if len(elements) == 0:
        return [[]]
    permutations = []
    for e in elements:
        reduced = elements[:]
        reduced.remove(e)
        reducedPermutations = generateListPermutations(reduced, level + 1)
        #print(" "*level, "reduced", reducedPermutations)
        for p in reducedPermutations:
            p.insert(0, e)
            permutations.append(p)
    return permutations