function DeletableItems = getDeletableItems(CB, ExcludeIOPorts) %#ok<INUSD>
% All level-1 blocks (that is, not couting CB).

% Copyright 2020-2022 The MathWorks, Inc.

AllItems = find_system(CB,'FollowLinks','on','LookUnderMasks','all',...
   'SearchDepth',1);
lvl0Items = find_system(CB,'FollowLinks','on','LookUnderMasks','all',...
   'SearchDepth',0);
DeletableItems = setdiff(AllItems,lvl0Items);

if nargin>1
   doNotDeleteItems1 = find_system(DeletableItems,'MatchFilter',@Simulink.match.allVariants, 'BlockType', 'Inport' ); 
   doNotDeleteItems2 = find_system(DeletableItems,'MatchFilter',@Simulink.match.allVariants, 'BlockType', 'Outport' ); 
   DeletableItems = setdiff(DeletableItems,[doNotDeleteItems1;doNotDeleteItems2]);
end
