Bug 1080312: update iteration code from upstream r=jesup