[IMPR] reduce code complexity of QueryGenerator.__iter__
[IMPR] reduce code complexity of QueryGenerator.__iter__

- Reduce cyclomatic complexity of submit from E37 to D23
  and improve readability by splitting code in parts.

Change-Id: Iaa1427ca3a0afc6bcc16e8ff379dabf5853fd36c

wikimedia/pywikibot-core,PersianWikipedia/pywikibot-core,wikimedia/pywikibot-core