In Service now want to compare 2 incidents

Hi Team,

Need help: compare incidents in service now.

  1. get mail about to check duplicate event code.
  2. I have to check mail event code name in each incident and see if same event code name matches with other incident.
  3. eg: First it open 1st incident and check event code with second incident in row, if matches then create new incident as parent one.
  4. But if no match then it should go to next incident. eg 3rd incident and compare 1st and 3rd.
    I can able to compare 1st and 2nd incident but if no match. It compare 2nd and 3rd incident, instead of 1st and 3rd incident.

Can anyone help me out.