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: strrep_recurse.m
    path of file: ./repos/CanlabCore/CanlabCore/Misc_utilities
    
    the code of the file until where you have to start completion: function new_var = strrep_recurse(old_var, old_string, new_string, depth)
% Recursively traverses depth-first through an entire variable, replacing
% old_string with new_string everywhere it goes
%
% :Usage:
% ::
%
%     new_var = strrep_recurse(old_var, old_string, new_string)

    MAX_DEPTH = 200;
    new_var = old_var;

    if(~exist('depth', 'var') || isempty(depth))

    
function new_var = strrep_recurse(old_var, old_string, new_string, depth)
% Recursively traverses depth-first through an entire variable, replacing
% old_string with new_string everywhere it goes
%
% :Usage:
% ::
%
%     new_var = strrep_recurse(old_var, old_string, new_string)

    MAX_DEPTH = 200;
    new_var = old_var;

    if(~exist('depth', 'var') || isempty(depth))
        depth = 1;
    elseif(depth > MAX_DEPTH)
        error('Exceeding max structure depth of %d. If this is legitimate, please edit this function.\n', depth);
    end