All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
What you mentioned is incorrect. The basic principle is that it is allowed to pass or sit under any tree - in a place where one is allowed to pass - at any time of the day or night. Allah, The Exalted, allowed human beings to benefit from everything that He created on this earth unless it is something that has been authentically declared unlawful in Islam.
Ibn ‘Aashoor wrote, "Allah, The Exalted, says (what means): {It is He Who created for you all of that which is on the earth...} [Quran 2:29] Scholars deduced from this verse that the basic principle is that using everything in any desired way is allowed unless there is proof in the Sharia that it is not allowed, because Allah created and subjected everything on earth for mankind and informed us that this is a favor that He bestowed upon us." [At-Tahreer wa At-Tanweer]
Allah knows best.