var
iFindRec, iParentRec: IGSPRecord;
begin
Result := -1;
iFindRec := FSection.FindByID(ASectionID);
if not Assigned(iFindRec) then Exit;
iParentRec := iFindRec.FindField(pfnPID).MasterRecord;
while iParentRec <> nil do
begin
iFindRec := iParentRec;
iParentRec := iFindRec.FindField(pfnPID).MasterRecord;
end;
Result := iFindRec.ID;
end;