In the previous editions of the game, nightmares were denizens of the Outer Planes and were not described as some corrupted versions of something else. Hence any purification story is unlikely to be found. For example, the 1e Monster Manual from 1977 simply states:
Also known as "demon horses" and "hell horses," nightmares are creatures from the lower planes.
The 1994 Planescape Monstrous Compendium (2e) provides quite some lore about nightmares, like how to attract the attention of one to acquire its services as a mount, how they go to a place called the Hill of Bone in Hades when they die, that they have no biological link to true horses, and their lack of need for food or air as they are minions of evil. Yet, no mention of pegasi:
Nightmares, the evil steeds of the Lower Planes, serve as mounts for baatezu, tanar'ri, night hags, and powerful undead lords.
Likewise we see nightmares in various random encounter tables in the 3e Manual of Planes, and statements that imply large numbers of nightmares, making it difficult to think that all of them can actually be transformed from pegasi. For example under the section about Hades (page 108), we read:
Besides Blood War detritus, night hags, and petitioners, Hades hosts herds of fiery nightmares.
It might perhaps be possible to redeem nightmares the way other fiends are redeemed, but I guess the question is about reverting/countering the process through which pegasi are turned into nightmare.
Hence if we decide to look for a 5e answer, one relevant piece of data comes from Mike Mearls, who tweeted the following on July 25, 2017 when asked about "a documented way a nightmare can turn back into a unicorn":
Nightmares are made from pegasi. In any case, bathe in waters of Mt Celestia to redeem its heart and restore form.