efficient removeMultipleEdges() function.