Нашёл решение в документации, мне подошел вариант:
if (CModule::IncludeModule("iblock")) {
$filter = [
'IBLOCK_ID' => 2,
];
$select = [
'NAME',
'SECTION_PAGE_URL',
];
$dbSection = CIBlockSection::GetList(
[
'LEFT_MARGIN' => 'ASC',
],
array_merge(
[
'ACTIVE' => 'Y',
'GLOBAL_ACTIVE' => 'Y',
],
is_array($filter) ? $filter : []
),
false,
array_merge(
[
'ID',
'IBLOCK_SECTION_ID',
],
is_array($select) ? $select : []
)
);
while ($arSection = $dbSection->GetNext(true, false)) {
$SID = $arSection['ID'];
$PSID = (int)$arSection['IBLOCK_SECTION_ID'];
$arLincs[$PSID]['CHILDS'][$SID] = $arSection;
$arLincs[$SID] = &$arLincs[$PSID]['CHILDS'][$SID];
}
$arResult['SECTIONS'] = array_shift($arLincs);
}