The mass of a tree is primarily carbon. The carbon comes from carbon dioxide used during photosynthesis. During photosynthesis, plants convert the sun's energy into chemical energy which is captured within the bonds of carbon molecules built from atmospheric carbon dioxide and water.
( hope this helps )