function root_sys = bdroot(sys)
%BDROOT Return the root level block diagram.
%	BDROOT(sys), where sys is the name of a SIMULINK
%	model or block, returns the root level block diagram.
%	If BDROOT is called with no arguments or if sys is
%	empty, BDROOT returns the root level block diagram
%	of the current SIMULINK model.

%	Copyright (c) 1990-94 by The MathWorks, Inc.
%	Rick Spada	3-8-93

if nargin==0,
  sys=get_param;
end

while ~isempty(get_param(sys,'Parent')),
  sys=get_param(sys,'Parent');
end;

root_sys=sys;
