def getItem(ilist, k):
    """
    Return the k-th item of the ilist
        or the last when not enough
        or the ilist itself when it is not a list

    Parameters
    ----------
    ilist : an item or a list of items
        List to obtain an item from
    k : int
        item to be returned

    """
    return ilist if not isinstance(ilist, list) else ilist[-1] if k >= len(
        ilist) else ilist[k]
