Avoid changing set size during iter in query plan generation

Fixes #87
Fixes PYTHON-54