code: public static <Item extends IItem> void addAllSubItems(Item item, List<Item> items) {
          if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
              List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
              Item subItem;
              for (int i = 0, size = subItems.size(); i < size; i++) {
                  subItem = subItems.get(i);
                  items.add(subItem);
                  addAllSubItems(subItem, items);
              }
          }
      }
docs: Gets all subItems from a given parent item
  
  @param item  the parent from which we add all items
  @param items the list in which we add the subItems