def iteritems(kvlist):
    """
    Iterate over (key, value) pairs in a sequence. 
    The sequence can be a list/tuple/iterator over (key, value) tuples,
    or a dict over values. 
    """
    if isinstance(kvlist, dict):
        return kvlist.items()
    else:
        return kvlist