[CODE]$sectionID = $N1;
$parentSectionID = $N2;
$arParentSection = CIBlockSection::GetByID($parentSectionID)->Fetch();
$res = CIBlockSection::GetList(false, array('ID'=>$sectionID, '>LEFT_BORDER' => $arParentSection['LEFT_MARGIN'], '<RIGHT_BORDER' => $arParentSection['RIGHT_MARGIN']));
if($res->SelectedRowsCount()) echo 'N1 потомок N2'; else '-';[/CODE]
$parentSectionID = $N2;
$arParentSection = CIBlockSection::GetByID($parentSectionID)->Fetch();
$res = CIBlockSection::GetList(false, array('ID'=>$sectionID, '>LEFT_BORDER' => $arParentSection['LEFT_MARGIN'], '<RIGHT_BORDER' => $arParentSection['RIGHT_MARGIN']));
if($res->SelectedRowsCount()) echo 'N1 потомок N2'; else '-';[/CODE]