private int addFilteredSubItems(List<T> values,T item){
  if (isExpandable(item)) {
    IExpandable expandable=(IExpandable)item;
    if (hasSubItems(expandable)) {
      List<T> filteredSubItems=new ArrayList<>();
      List<T> subItems=expandable.getSubItems();
      for (      T subItem : subItems) {
        if (!subItem.isHidden())         filteredSubItems.add(subItem);
      }
      values.addAll(filteredSubItems);
      return filteredSubItems.size();
    }
  }
  return 0;
}

private int addFilteredSubItems ( List < T > values , T item ) { if ( isExpandable ( item ) ) { IExpandable expandable = ( IExpandable ) item ; if ( hasSubItems ( expandable ) ) { List < T > filteredSubItems = new ArrayList < > ( ) ; List < T > subItems = expandable . getSubItems ( ) ; for ( T subItem : subItems ) { if ( ! subItem . isHidden ( ) ) filteredSubItems . add ( subItem ) ; } values . addAll ( filteredSubItems ) ; return filteredSubItems . size ( ) ; } } return 0 ; }
adds to the final list also the filtered subitems .
