def iter_rec(found, fL, bL):
    if fL and bL:
        ik = found[-1] if found else 0
fk = fL[0]
bk = bL[0]
for i in range(fk(ik), bk):
    for item in iter_rec(found + [i], fL[1:], bL[1:]):
        yield item
else:
    yield found
F = [lambda x: 0] + F
current = [item for item in iter_rec([], F, B)]
Using itertools for arbitrary number of nested loops of different ranges with dependencies?