def makeNext(x, k):
    """
    Return next item of x, and last item if x is exhausted.
    Or x itself if x is singular.
    """
    try:
        _xnext = x[-1]
    except:
        _xnext = x
    while True:
        try:
            _xnext = x[k]
            yield _xnext
            k += 1
        except:
            yield _xnext
