def iteritems(dictionary):
    """
  Function to use the generator-based items iterator over built-in
  dictionaries in both Python 2 and 3.
  """
    try:
        return getattr(dictionary, 'iteritems')()
    except AttributeError:
        return iter(getattr(dictionary, 'items')())
