The Jataka, Vol. III, tr. by H.T. Francis and R.A. Neil, , at sacred-texts.com
 "Who is it that wakes," etc.—The Master told this tale while dwelling in Jetavana, concerning a certain lay-brother. He was a disciple who had entered on the First Path. He set out by a forest road from Sāvatthi with a caravan of carts. At a certain pleasant watered spot the leader of the caravan unyoked five hundred carts, and arranging for food, both hard and soft, he took up his lodging there. The men lay down here and there to sleep. The lay-brother practised perambulation at the root of a tree near the leader of the caravan. Five hundred robbers planned to plunder the caravan: with various weapons in their hands they surrounded it and waited. Seeing the lay-brother at his walk they stood waiting to begin plundering when he should go to sleep. He went on walking all night. At dawn the robbers threw away the sticks and stones and other weapons they had picked up: they went away, saying, "Master Caravan-leader, you are owner of your property because you have got your life owing to that man who keeps awake so diligently: you should pay honour to him." The caravan-men rising betimes saw the stones and other things thrown away by the robbers and gave honour to the lay-brother, recognising that they owed their lives to him. The lay-brother went to his destination and did his business: then he returned to Sāvatthi and went on to Jetavana: there he saluted and did homage to the Tathāgata and sat at his feet, and on his invitation to declare himself, he told the tale. The Master said, "Lay-brother, it is not you alone who have gained special merit by waking and watching, wise men of old did the same." And so at the lay-brother's request, he told an old story.
Once upon a time when Brahmadatta was reigning in Benares, the Bodhisatta was born in a brahmin family. When he grew up he learned all the arts at Takkasilā, and then returning lived as a householder. After a time he left his house and became an ascetic: soon he reached the Faculty of Meditation, and living in the Himālaya quarter in the standing and walking attitudes only, he walked all night without sleeping.  A spirit who lived in a tree at the end of his walk was pleased with him and spoke the first stanza, putting a question to him from a hole in the trunk:—
Who is it can read my riddle, who to this will answer make?
The Bodhisatta, hearing the spirit's voice, spoke this stanza:—
I am he can read your riddle, I to you can answer make.
The spirit put a question again in this stanza:—
How is it you read my riddle, how this answer do you make?
He explained the point:—
Passion and vice and ignorance in some have ceased to be: So it is I wake while others sleep, and sleep while others wake:
When such are sleeping I'm awake, O spirit of the tree.
When such are waking then I sleep, O spirit of the tree.
So it is I read your riddle, so to you I answer make.
Passion and vice and ignorance in some have ceased to be:
So it is I wake while others sleep, and sleep while others wake:
 When the Great Being gave this answer, the spirit was pleased and spoke the last stanza in his praise:—
Good your reading of my riddle, good the answer that you make.
And so making the Bodhisatta's praises, the spirit entered its abode in the tree.
After the lesson, the Master identified the Birth: "At that time, the tree-spirit was Uppalavaṇṇā, the ascetic was myself."