he had been wandering for hours in the wood , in which every tree seemed so alike that he couldnt imagine how hed ever found his way out again , when he remembered the golden leaves and pulled them out of his pocket .