Rabbi Rahumai said: From your words we could conclude that the needs of this world were created before the heavens. He answered yes. What does this resemble? A king wanted to plant a tree in his garden. He searched the entire garden to find a spring flowing with water that would nourish the tree, but could not find any. He then said, "I will dig for water, and will bring forth a spring to nourish the tree." He dug and opened a well, flowing with living water. He then planted the tree, and it stood, giving forth fruit. It was successfully rooted, since it was always watered from the well.
Illumination of the Bahir
Sefer HaBahir 1:23