How to use itertools in Python for efficient, powerful loops