@ Nonnull @ ReturnsMutableCopy public static < KEYTYPE , DATATYPE , ITEMTYPE extends ITreeItemWithID < KEYTYPE , DATATYPE , ITEMTYPE > > ICommonsList < ITEMTYPE > findAllItemsWithIDRecursive ( @ Nonnull final ITEMTYPE aTreeItem , @ Nullable final KEYTYPE aSearchID ) { final ICommonsList < ITEMTYPE > aRetList = new CommonsArrayList <> ( ) ; TreeVisitor . visitTreeItem ( aTreeItem , new DefaultHierarchyVisitorCallback < ITEMTYPE > ( ) { @ Override @ Nonnull public EHierarchyVisitorReturn onItemBeforeChildren ( @ Nullable final ITEMTYPE aItem ) { if ( aItem != null && aItem . getID ( ) . equals ( aSearchID ) ) aRetList . add ( aItem ) ; return EHierarchyVisitorReturn . CONTINUE ; } } ) ; return aRetList ; }
Fill all items with the same ID by linearly scanning the tree .