Backport hash_iterator from master to fix Bug#1031330