The check (leftOccurrences > 0) is not needed here. You can find such problems when looking at your test coverage in EclEmma: it will tell you that some branches have been missed in this condition.