tail-recursive version of python itertools.repeat