py3: handle iteritems

dict.iteritems is depreciated. Create a function to decide
whether to use iteritems or iter(items)
py3: handle itervalues

itervalues is depreciated. Create a function to decided
whether to use itervalues or iter(values)
loose the use of map

replace with lists and generators