The Freestyle iterators had a big flaw when being used in for loops, being that the iterator object wasn't in sync with the object returned by
next(). This would crash when referencing the iterator on the final iteration (it.object would point to nothing).
This patch fixes that by not incrementing the iterator on the first call of next() (iternext internally). to make sure referencing the iterator object doesn't crash, the iterator is also validated by checking whether it has reached its end. since the iterator object should now always be valid, the changes made in revision rBc592ebf5df4a2be3b70bd3e2f2bba0e3d5908704 and revision 61233 can be reverted.
This change does not have any influence on the operation of current scripts, but will allow the use of for loops in more cases in the future.
NB: I also changed 'reversed' to be a bool, but it seems that reversed is not referenced from the outside (nor is it referable through the api)
to me it seems that reversed could be removed. if someone needs a reversed iterator, the reversed() Python built-in should be used.