function [resultIds, resultInfo] = queryResultsFromRunUnderModel(modelName, blockObject, pathItem, runName)
%% QUERYRESULTSFROMRUNUNDERMODEL function filters all results of a block 
% object and path item across all models in a model reference hierarchy for
% a given run name

%   Copyright 2018-2020 The MathWorks, Inc.

    resultIds = {};
    resultInfo = [];
    allDatasets = fxptds.Utils.getAllDatasetsUnderModel(modelName);
    for idx=1:numel(allDatasets)
        runNames = allDatasets{idx}.getAllRunNames;
        if ~any(ismember(runNames, runName))
            continue;
        end
        runObject = allDatasets{idx}.getRun(runName);
        result = runObject.getResult(blockObject, pathItem);
        if ~isempty(result) 
            if result.hasInterestingInformation
                resultIds{end+1} = result.getScopingId; %#ok
                resultInfo = fxptds.QueryResultStatus.FOUND_WITH_INTERESTING_INFORMATION;
            else
                resultInfo = fxptds.QueryResultStatus.NO_INTERESTING_INFORMATION;
            end
        else
            resultInfo = fxptds.QueryResultStatus.NOT_FOUND;
        end
    end
end
