Out of his tree

What is the origin of "Out of his tree" as a metaphor for "crazy"?