function ind = mgetkids(sbkids,bkkids,node)
%MGETKIDS
%
%  IND = MGETKIDS(SBKIDS,BKKIDS,NODE);

% Initial coding by A S Bozin, 5-17-97
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2000/06/14 16:12:26 $

   %
   % Allocate memory and then recursively find all kids
   %
   sel = zeros(size(sbkids));
   sel(:) = getkids(sel,sbkids,bkkids,node);
   ind = find(sel);
   return					   % Last card of MGETKIDS
   
function sel = getkids(sel,sbkids,bkkids,node)
%GETKIDS
%

   %
   % Find the kids associated with the superblocks
   %
   for (k = sbkids{node})
      if (sel(k) == 0)
	 sel(k) = 1;
	 sel(:) = getkids(sel,sbkids,bkkids,k);
      end
   end
   %
   % Find the kids associated with the blocks
   %
   kids = bkkids{node};
   if (~isempty(kids))
      nblk = size(kids,2);
      for (cb = 1:nblk)
	 for (k = kids{cb})
	    if (sel(k) == 0)
	       sel(k) = 1;
	       sel(:) = getkids(sel,sbkids,bkkids,k);
	    end
	 end
      end
   end
   return					   % Last Card of GETKIDS
