function &findOrCreateLookupByPermissionDescriptorMap($aMapPermDesc)
 {
     $aOptions = array();
     foreach ($aMapPermDesc as $iPermissionID => $iDescriptorID) {
         $aThisOptions = array();
         foreach (KTPermissionLookupAssignment::_getLookupIDsByPermissionIDAndDescriptorID($iPermissionID, $iDescriptorID) as $iPLID) {
             $aThisOptions[] = $iPLID;
         }
         $aOptions[] = $aThisOptions;
     }
     if (count($aOptions) > 1) {
         $aPLIDs = call_user_func_array('array_intersect', $aOptions);
     } elseif (count($aOptions) == 1) {
         $aPLIDs = $aOptions[0];
     } else {
         $aPLIDs = array();
     }
     if (empty($aPLIDs)) {
         $oPL = KTPermissionLookup::createFromArray(array());
         $iPLID = $oPL->getID();
         foreach ($aMapPermDesc as $iPermissionID => $iDescriptorID) {
             $res = KTPermissionLookupAssignment::createFromArray(array('permissionlookupid' => $iPLID, 'permissionid' => $iPermissionID, 'permissiondescriptorid' => $iDescriptorID));
         }
         return $oPL;
     }
     sort($aPLIDs);
     $res = KTPermissionLookup::get($aPLIDs[0]);
     return $res;
 }