Why didn't Nagato revive Yahiko? Using Nagato's power, he can revive the dead. I saw him reviving Pain's member everytime someone die (except for the reviver member of course). He also revive a lot of people he killed in Konoha. But I don't understand why didn't he revive Yahiko then?
I was thinking he discovered the reviving jutsu after a while Yahiko died, and some soul cannot be revive after a long time of being dead. But that idea removed when I think about how Madara revive himself.
Nagato was actually reconstructing their dead bodies  and not reviving (in the sense of bringing them back to life), because the &quot;six pains&quot; were basically just walking corpses being controlled through black recievers that transmit chakra.
Using the Naraka Path, Nagato was able to use one of those pains to summon the King Of  Hell who could repair/fix their corpses. According to the wiki:

The King of Hell can repair any damage done to the Six Paths of Pain, which it accomplishes by grabbing their damaged forms with its tongue and consuming them.

On the other hand, the Samsara of Heavenly Life (reincarnation jutsu) comes at the cost of the casters life.