   WHERE country = countrycode_id
    AND area = inAreaCode
    AND number = inNumber
+  LIMIT 1
  );
 END;
 $$ LANGUAGE plpgsql;

     AND Part.parent IS NOT NULL
     AND Part.version IS NULL
     AND Part.serial IS NULL
   );
   IF parent_id IS NULL THEN
    -- Try same part without version or parent (root part)

  AND agentString = inAgentString
  AND fromAddress = inIPAddress
  AND ((referring = referringURL) OR (referring IS NULL AND referringURL IS NULL))
  LIMIT 1
 );

 IF existingSession IS NULL THEN
