% get the list of all leafs of a parameter with name 'paramName' in an array
function parameterList = createFlatParamList(paramValue)

%   Copyright 2020 The MathWorks, Inc.

    parameterList = [];
    if isstruct(paramValue)
        leafFieldNames = fieldnames(paramValue); 
        for idx = 1:length(leafFieldNames)
            if idx == 1
                parameterList = Sldv.ParameterTuning.Manager.createFlatParamList(...
                    paramValue.(leafFieldNames{idx}));
            else
                parameterList = [parameterList Sldv.ParameterTuning.Manager.createFlatParamList(...
                    paramValue.(leafFieldNames{idx}))]; %#ok<AGROW>
            end
        end
    else
        if isempty(parameterList)
            parameterList = paramValue;
        else
            parameterList(end+1) = paramValue;
        end
    end
end
