Utility functions for working with iterators.