Iterable<FoldedBlock> () { return () -> new Iterator<>() { private int myGroupIndex = 0; private int myBlockIndex = 0; @Override public boolean hasNext() { return myGroupIndex < myFoldings.size(); } @Override public FoldedBlock next() { FoldedGroup group = myFoldings.get(myGroupIndex); FoldedBlock folding = group.blocks.get(myBlockIndex); if (group.blocks.size() > myBlockIndex + 1) { myBlockIndex++; } else { myGroupIndex++; myBlockIndex = 0; } return folding; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }