I'm trying to check if the two nodes
are the same, meaning that they have
the same number of children, and that
those children lead to the exact same
states. Therefore, I'm effectively
trying to compare the subtrees at the
two node. I'm wondering if I can use
hashing to do this equality check.
No, hashing should not be used to check equality. That's not its purpose. It can eventually help you find out if objects are not equal, but it won't tell anything you if they are equal.
Same objects will generate same hash value, but two different objects which are not equal can generate the same hash too. In other words, if hash values are different, you know for sure that objects are different. That's it.
If you want to test equality, you need to implement equals. In your case, there is a danger that your method will go recursive and provoke a stack overflow. What if your object contains a reference to itself?
If you want to generate a hash, you could take the size of the array into account (and the fact that it is null or not), but I would not try to use the hash value of the objects in the array, because of potential infinite loops. It is not perfect, but it is good enough.
There is another radical method which may provide good result too. Instead of computing hash values dynamically, set a random int value for each Node object instance (I mean once for all at creation and always return that value). In your case, you would not risk infinite loops by taking the hash value of the object instances in your array.
If hashes are equals, then you would need to start comparing array object instances.
REM: If Nodes contain other attributes, then compute hash on these other attributes and forget about the array. Start investigating about array content/size if and only if hash are identical between two objects.
REM2: Comments mentions DAG graph, which means we won't hit recursivity issues. However, that condition is not enough that guarantee that deepHashCode() will succeed. Moreover, it would be overkill too. There is a more efficient way to solve this issue.
If the hash method used by Node only uses the array to compute a hash value, then deepHashCode() may work. But it would not be efficient. If the hash method uses other node attributes, then these attributes would have to be equal too.
There is a faster way to compare nodes for equality. Mark each node instance with a unique number. Then, to compare two nodes, compare their array size first. If it is equals, then compare nodes from each array using their unique number. If one array does not 'have' the other node, then we are not dealing with equal nodes. This solution is much faster than going recursive.