void (final Iterator<List<String>> batches, final List<String> pending, int counter) { while (counter > 0 && batches.hasNext()) { pending.addAll(batches.next()); while (pending.size() > 10 || !pending.isEmpty() && !batches.hasNext()) { counter -= returnSomeValue(); if (counter == 0) break; updatePending(pending); } assert <selection>counter == 0 || batches.hasNext() || pending.isEmpty()</selection>; } }