function compiledInfo = getBusCompiledInfo(treeOrBlock, compiledInfo, busSelector)
    currentIndex = length(compiledInfo) + 1;
    if ishandle(treeOrBlock)
        tree = Simulink.BlockDiagram.Internal.getInterfaceModelBlock(treeOrBlock).port.tree;
    else
        tree = treeOrBlock;
    end    
    ca = tree.childAttrs;
    pa = tree.parentAttrs;
    ba = tree.blockAttrs;
    
    if any(isvalid(ca))
        % This means there is a branch
        
        compiledInfo(currentIndex).DataType = Simulink.internal.CompositePorts.TreeNode.getDataType(tree);
        compiledInfo(currentIndex).Complexity  = char(Simulink.internal.CompositePorts.TreeNode.getComplexity(tree));
        compiledInfo(currentIndex).Dimensions = str2num(Simulink.internal.CompositePorts.TreeNode.getDims(tree)); %#ok<ST2NM>
        compiledInfo(currentIndex).SampleTime = str2double(Simulink.internal.CompositePorts.TreeNode.getSampleTime(tree));
        compiledInfo(currentIndex).SamplingMode = 'Sample based';

        busStr = strsplit(ca.parent.signalAttrs.dataType,':');
        compiledInfo(currentIndex).BusObjPath = strjoin(strtrim(busStr(2:end)),'/');
        compiledInfo(currentIndex).SignalPath = [busSelector '.' ca.name];
        compiledInfo(currentIndex).Used = isvalid(ba);
    end
    if isvalid(pa)
        children = pa.children.toArray();
        for i = 1:numel(children)
            compiledInfo = getBusCompiledInfo(children(i), compiledInfo,busSelector);
        end
    end
    
end
