Trouble understanding octet string (binary) iteration

If the early exit really makes a difference, you could also do explicit recursion.