public final TradingCatalog findTradingCatalogById(
    final List<TradingCatalog> pCatalogs,
      final Long pId) {
    for (TradingCatalog cat : pCatalogs) {
      if (cat.getCatalog().getItsId().equals(pId)) {
        return cat;
      }
      if (cat.getSubcatalogs().size() > 0) {
        //recursion:
        TradingCatalog tc = findTradingCatalogById(cat.getSubcatalogs(), pId);
        if (tc != null) {
          return tc;
        }
      }
    }
    return null;
  }
public final TradingCatalog findTradingCatalogById ( final List < TradingCatalog > pCatalogs , final Long pId ) { for ( TradingCatalog cat : pCatalogs ) { if ( cat . getCatalog ( ) . getItsId ( ) . equals ( pId ) ) { return cat ; } if ( cat . getSubcatalogs ( ) . size ( ) > 0 ) { TradingCatalog tc = findTradingCatalogById ( cat . getSubcatalogs ( ) , pId ) ; if ( tc != null ) { return tc ; } } } return null ; }
<p>Find trading catalog by ID.</p>
@param pCatalogs trading catalogs
@param pId Catalog ID
@return Trading Catalog