Here is the sutta text (AN 3.36) on the fist divine messenger:
“Here, bhikkhus, someone engages in misconduct by body, speech, and mind. In consequence, with the breakup of the body, after death, he is reborn in the plane of misery, in a bad destination, in the lower world, in hell. There the wardens of hell grab him by both arms and show him to King Yama, saying: ‘This person, your majesty, did not behave properly toward his mother and father; he did not behave properly toward ascetics and brahmins; and he did not honor the elders of the family. May your majesty inflict due punishment on him!’
(1) “Then King Yama questions, interrogates, and cross-examines him about the first divine messenger: ‘Good man, didn’t you see the first divine messenger that appeared among human beings?’ And he replies: ‘No, lord, I didn’t see him.’
“Then King Yama says to him: ‘But, good man, didn’t you ever see among human beings a man or a woman, eighty, ninety or a hundred years of age, frail, bent like a roof bracket, crooked, wobbling as they go along leaning on a stick, ailing, youth gone, with broken teeth, with grey and scanty hair or bald, with wrinkled skin and blotched limbs?’ And the man replies: ‘Yes, lord, I have seen this.’
“Then King Yama says to him: ‘Good man, didn’t it occur to you, an intelligent and mature person: “I too am subject to old age, I am not exempt from old age. Let me now do good by body, speech, and mind”?’ —‘No, lord, I could not. I was heedless.’
“Then King Yama says: ‘Through heedlessness, good man, you failed to do good by body, speech, or mind. Surely, they will treat you in a way that fits your heedlessness. That bad kamma of yours was not done by your mother or father, nor by your brother or sister, nor by your friends and companions, nor by your relatives and family members, nor by the deities, nor by ascetics and brahmins. Rather, you were the one who did that bad kamma, and you yourself will have to experience its result.’
It is easy to be mislead by the first paragraph of the sutta, in which the wardens of hell ask King Yāma to inflict appropriate punishment. But if you read the whole sutta carefully, you will see that King Yāma does in fact not inflict any punishment. Instead he says: “Surely, they will treat you in a way that fits your heedlessness. … Rather, you were the one who did that bad kamma, and you yourself will have to experience its result.” King Yāma is just reminding the person of what they have done.
I believe this is very similar to what many people experience during NDEs. People often experience a life review, and then a sense of judging whether they have lived well or badly. Just as in the story with King Yāma, it is the person who judges themselves. Even the idea of a King Yāma presiding over the questioning may not be purely allegorical. Apparently there are people who experience this sort of questioning by an authority figure during NDEs.
It was in fact Bhante Sujato who pointed this out to me many yeas ago.