function D = elimBranching(D,I,J)
% Eliminates input branching.
% Inputs U of D are assumed to be branches U = UU(J) of the unique
% set of input signals UU = U(I). Returns an equivalent model
% whose inputs are the unique signals UU.

%   Copyright 2020 The MathWorks, Inc.
nu = numel(J);
nuu = numel(I);
[~,nc] = iosize(D.IC);
nw = nc-nu;
D.IC = elimBranching(D.IC,[I;(nu+1:nu+nw)'],[J;(nuu+1:nuu+nw)']);