You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: save.m
    path of file: ./repos/fieldtrip/external/gifti/@xmltree
    
    the code of the file until where you have to start completion: function varargout = save(tree, filename)
% XMLTREE/SAVE Save an XML tree in an XML file
% FORMAT varargout = save(tree,filename)
%
% tree      - XMLTree
% filename  - XML output filename
% varargout - XML string
%__________________________________________________________________________
%
% Convert an XML tree into a well-formed XML string and write it into
% a file or return it as a string if no filename is provided.
%__________________________________________________________________________
% Copyright (C) 2002-2011  http://www.artefact.tk/

% Guillaume Flandin
% $Id: save.m 4460 2011-09-05 14:52:16Z guillaume $


%error(nargchk(1,2,nargin));

prolog = '<?xml version="1.0" ?>\n';

%- Return the XML tree as a string
if nargin == 1

    
function varargout = save(tree, filename)
% XMLTREE/SAVE Save an XML tree in an XML file
% FORMAT varargout = save(tree,filename)
%
% tree      - XMLTree
% filename  - XML output filename
% varargout - XML string
%__________________________________________________________________________
%
% Convert an XML tree into a well-formed XML string and write it into
% a file or return it as a string if no filename is provided.
%__________________________________________________________________________
% Copyright (C) 2002-2011  http://www.artefact.tk/

% Guillaume Flandin
% $Id: save.m 4460 2011-09-05 14:52:16Z guillaume $


%error(nargchk(1,2,nargin));

prolog = '<?xml version="1.0" ?>\n';

%- Return the XML tree as a string
if nargin == 1
    varargout{1} = [sprintf(prolog) ...
        print_subtree(tree,'',root(tree))];
%- Output specified
else
    %- Filename provided
    if ischar(filename)
        [fid, msg] = fopen(filename,'w');
        if fid==-1, error(msg); end