During the day time the leaves of the trees give off a plenty of oxygen in the process of photosynthesis. The amount of oxygen given off far exceeds the amount of carbon dioxide given out by the process of the tree respiring.
At night, there is no sunlight and photosynthesis stops. The trees however, continue to respire. As a result, trees give out carbon dioxide at night. Therefore, it is not advisable to sleep under a tree at night.