Bug 1080312 - Update iteration code from upstream. r=jesup, a=abillings