public static <Item extends IItem> void restoreSubItemSelectionStatesForAlternativeStateManagement(Item item, List<String> selectedItems) {
        if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
            List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
            for (int i = 0, size = subItems.size(); i < size; i++) {
                Item subItem = subItems.get(i);
                String id = String.valueOf(subItem.getIdentifier());
                if (selectedItems != null && selectedItems.contains(id)) {
                    subItem.withSetSelected(true);
                }
                restoreSubItemSelectionStatesForAlternativeStateManagement(subItem, selectedItems);
            }
        }
    }
public static < Item extends IItem > void restoreSubItemSelectionStatesForAlternativeStateManagement ( Item item , List < String > selectedItems ) { if ( item instanceof IExpandable && ! ( ( IExpandable ) item ) . isExpanded ( ) && ( ( IExpandable ) item ) . getSubItems ( ) != null ) { List < Item > subItems = ( List < Item > ) ( ( IExpandable < Item , ? > ) item ) . getSubItems ( ) ; for ( int i = 0 , size = subItems . size ( ) ; i < size ; i ++ ) { Item subItem = subItems . get ( i ) ; String id = String . valueOf ( subItem . getIdentifier ( ) ) ; if ( selectedItems != null && selectedItems . contains ( id ) ) { subItem . withSetSelected ( true ) ; } restoreSubItemSelectionStatesForAlternativeStateManagement ( subItem , selectedItems ) ; } } }
internal method to restore the selection state of subItems

@param item          the parent item
@param selectedItems the list of selectedItems from the savedInstanceState