Merging Fully identical nodes

Here i am trying to merge all the nodes that are totally identical to each other, but when i execute the below query its throwing error. Can anyone please help me to resolve this issue.

// Step 1: Find pairs of identical nodes (excluding the 'hex_id' property)

MATCH (n1), (n2)

WHERE id(n1) < id(n2)

AND labels(n1) = labels(n2)

AND apoc.map.removeKey(properties(n1), 'hex_id') = apoc.map.removeKey(properties(n2), 'hex_id')

// Step 2: Merge the nodes using APOC procedure

WITH n1, n2

CALL apoc.refactor.mergeNodes([n1, n2], {properties: "overwrite", mergeRels: true})

YIELD node AS merged_node

RETURN id(merged_node) AS merged_node_id

ERROR:
Failed to invoke procedure apoc.refactor.mergeNodes: Caused by: org.neo4j.graphdb.NotFoundException: Node 15777 not found

I think it is because you are merging in pairs and you have groups of identical nodes that consist of more than two nodes. As you merge, all but the first node in the merge nodes list is removed. This means those groups of nodes with the same labels and properties that consist of more than two nodes will have an issue when merging pairs in the group after the first pair is merged. Eventually you will get the 'node not found' message.

Does you data have this property?

yes i am having more then two identical nodes. I have attached few screenshots as well.