Hash codes will not be identical "if and only if the data is identical". There are more possible trees than possible hash codes, so there will be many trees with the same hash code. What you need to achieve: Two trees that compare equal have the same hash code, and two trees with different hash codes don't compare equal.
First question: When do you consider two trees equal? A tree is really just a sorted list, with some structure to find things quickly, and to add and remove items quickly (faster than in a sorted list using an arrow). So I would consider two trees equal if they are each a sorted list of items with equal hash codes. The tree structure can be different, but we usually don't care about that.
You need an algorithm that calculates the same hash value independent of the actually tree structure. You can with brute force just calculate a hash code from all hash values in the tree structure. Or you can find the elements with index k/8, 3k/8, 5k/8 and 7k/8 where k is the number of elements.