Github user krlohnes commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/838#discussion_r181402263 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatStep.java --- @@ -273,11 +314,37 @@ public RepeatEndStep(final Traversal.Admin traversal) { super(traversal); } + final LinkedList<Traverser.Admin<S>> stashedStarts = new LinkedList<>(); + + private Traverser.Admin<S> nextStart(RepeatStep<S> repeatStep) { + if (repeatStep.searchAlgo.equals(SearchAlgo.BFS)) { + return this.starts.next(); + } else { + if (this.starts.hasNext()) { + return this.starts.next(); + } else { + return this.stashedStarts.pop(); + } + } + } + + @Override + public boolean hasNext() { + return super.hasNext() || this.stashedStarts.peek() != null; --- End diff -- Fixed
---