I am working in Python. I want to make a function that takes two values: `maxSum` and `n`. The output should be all the `n`-tuples of non-negative integers that add up to `maxSum` or less. For example, if `maxSum` is 2 and `n` is three, the output should be:

`[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 0], [0, 1, 1], [0, 2, 0], [1, 0, 0], [1, 0, 1], [1, 1, 0], [2, 0, 0]]`

For any given value of `n`, I can do it, just by going through `n` for-loops. For example, if `n` is 3, I can simply do:

```
result = []

for i in range(maxSum + 1):
    for j in range(maxSum + 1 - i):
        for k in range(maxSum + 1 - i - j):
            tuple = [i, j, k]
            result.insert(len(result), tuple)
return result

```

But in the above example, I have typed the three for-loops by hand. That is not what I want. I want to be able to make a function that works for any `n`, that is, a function `tupleGenerator(maxSum, n)` that generates all such n-tuples. The problem is, I am unable to change the number of for-loops in the function based on the input `n`.