As the title suggest, is the value based on the content of all tree objects(recursively) inside?
Namely, can I regard two tree objects as the exactly same file tree (including all the subdirectories and files) if they have the same hash value?
You can see some rough details about what is used to calculate the tree SHA here.
Further information about the binary format that the tree is stored in can be found here.
The actual SHA that is used is just the SHA of the buffer described in that detailed version.
The key points to take home is that the SHA is dependent on the filenames of all contained objects or trees, their SHAs and their permissions. Change any of those and you change the SHA. If two trees have the same SHAs then all those components must match (excluding the possibility of collisions as they're nigh on impossible).