function output = recursiveMethodCall(obj, methodName, parentObjects, varargin) parentObjects = [parentObjects, {obj}]; properties = string(fields(obj))'; for property = properties if skipProperty(obj.(property), parentObjects) continue end if ismember(methodName, methods(obj.(property))) eval("obj.(property)." + methodName + "(varargin{:});"); end recursiveMethodCall(obj.(property), methodName, parentObjects, varargin{:}); end end function output = skipProperty(parsedProperty, parentObjects) output = ... not(isobject(parsedProperty) | isstruct(parsedProperty))... | not(isscalar(parsedProperty))... | isstring(parsedProperty)... | isParent(parsedProperty, parentObjects); end function output = isParent(parsedProperty, parentList) output = false; for i = 1:length(parentList) if isequal(parentList{i}, parsedProperty) output = true; return end end end