Uses a flag to mark deletion of swapped nodes.