Avoid searching if an iterator is already positioned correctly.

Some fiddling to avoid const warnings.