more versatile squash iterator