Not only that, but I may also want to keep processing the loop and do something different if the value has already been set instead of returning immediately, which necessitates a second loop.
Can I ask why you require to handle it in one loop?As I see it, you are required to poll over isSet/isNotSet in every iteration.