Use iteritems and setdefault