You can use generators to simplify nested loops and make it easier to break out of them.
The 2 hardest problems in programming are naming, cache invalidation, and off-by-one errors.