function hOut = addNode(this, varargin)
% Overloaded addNode so that uitreenodes are conected

% If no leaf is supplied, add a default child
if isempty( varargin )
  leaf = this.createChild;
else
  leaf = varargin{1};
end

if isa( leaf, 'tsexplorer.node' )
  connect( leaf, this, 'up' );
  %drawnow
  %this.TreeNode.add(leaf.TreeNode);
elseif isempty(leaf)
  % removed
  % warning( 'Leaf node is empty.' )
else
  error( '%s is not of type @explorer/@node', class(leaf) )
end

if nargout > 0
  hOut = leaf;
end
