refactoring graphsceneiterator to avoid code duplication