Dharma, disguised as a Yaksha guarding a lake, strikes down four Pandavas and restores them when Yudhishthira answers his questions and chooses fairly.
Four brothers ignore a voice at a forest lake, drink and die. Yudhishthira answers the Yaksha: the mother is weightier than the earth, the father higher than the sky, the mind swifter than wind; a fish sleeps with open eyes; the greatest wonder is that the living think themselves immortal while creatures go daily to Yama. He asks for Nakula, Madri's son, to live; all four are revived. The Yaksha is Dharma, who was also the deer, and he grants three boons.
Three princes of Benares go into exile. A water spirit, licensed by Vessavana to eat all who enter its pool except those who know what is truly godlike, takes the two younger, who answer "sun and moon" and "the four quarters". The eldest, the Bodhisatta, stays out of the water, answers that the godlike are those who shrink from wrong, and, offered one brother, chooses the youngest, his stepmother's son. The spirit returns both and is converted.
What is different here:
A real water demon, one question, three brothers, no hidden god; the spirit is the one taught.
Sources: The Mahabharata, tr. K. M. Ganguli (1883-96), sections read for the Vedic layer; The Jataka, Volume I, tr. Robert Chalmers (1895), No. 6 Devadhamma Jataka