Inventories are containers for sub-inventories. You can do a deep recursion to get all the leaf nodes.
This is my response to another thread:
private Iterable<Slot> getSlots(Inventory inventory) {
if (inventory instanceof Slot) {
return Collections.emptyList();
}
Iterable<Slot> slots = inventory.slots();
for (Inventory subInventory : inventory) {
Iterables.concat(slots, getSlots(subInventory));
}
return slots;
}