Iterator<ChangesBunch> (final int bunchSize, final List<Long> revisions) { final List<ChangesBunch> list = new ArrayList<>(); for (int i = revisions.size() - 1; i >= 0; i -= bunchSize) { final int j = (bunchSize > i) ? -1 : (i - bunchSize); final List<CommittedChangeList> subList = new ArrayList<>(); for (int k = i; k > j; -- k) { subList.add(createList(revisions.get(k))); } list.add(new ChangesBunch(subList, (j != -1))); if (j == -1) { break; } } return list.iterator(); }