function sldvDeadPassthroughBlockGroup = removeUnreachableGroups(sliceTransformer, mdlCopy, mdl, ...
    deadBlocks, groups)
%

%   Copyright 2014-2020 The MathWorks, Inc.

% Collect all the dead SLDV blocks that are Pass-through
% these needs to be removed later.
sldvDeadPassthroughBlockGroup=[];
refMdlToMdlBlk = sliceTransformer.ms.refMdlToMdlBlk;

if ~isempty(groups.toChildren)
    g = groups.toChildren.keys;
    g = [g{:}];
    [handlesCopy, vg] = Transform.getCopyHandles(g, refMdlToMdlBlk, mdl, mdlCopy);
    for i=1:length(vg)
        if isGroupDead(vg(i))
            if(isPassThroughSLDVBlock(vg(i)))
                sldvDeadPassthroughBlockGroup(end+1) = handlesCopy(i);
            else
                if (strcmpi(get_param(vg(i),'BlockType'),...
                        get_param(handlesCopy(i),'BlockType'))) %Sanity check
                    Transform.removeDisabledSys(sliceTransformer, handlesCopy(i));
                end
            end
        end
    end
end
    function yesno = isGroupDead(bh)
        nvBlks = groups.getNVChildren(bh);
        if ~isempty(nvBlks)
            isdead = arrayfun(@(x)any(x == deadBlocks), nvBlks);
            yesno = all(isdead);
        else
            yesno = false;
        end
    end

    function yesno = isPassThroughSLDVBlock(bh)
        yesno = false;
        if strcmp(get(bh,'type'), 'block') && ...
            strcmp(get(bh,'Mask'),'on')
            isSLDVBlk = strfind(get(bh,'MaskType'),'Design Verifier');
            if(~isempty(isSLDVBlk))
                ph = get(bh,'PortHandles');
                if(~isempty(ph.Outport))
                    yesno = true;
                end
            end
        end
    end

end
