If the if clause in pattern matching has a side effect that keeps adding expect or expectOnce, we can run into an infinite loop as Roland suggested. This addition keeps new expects and expectOnce calls in a separate buffer outside the workList while processing. They will be appended to the workList after the processing. This prevents the traversed list from increasing in size while processing and has the same effect as using an immutable Vector without the performance penalty of recreating the Vector and more importantly, removing items from the Vector using patch.