In a transaction hierarchy, unload operations are currently executed per transaction, one after the other, starting with the leaf transaction, ending with the root transaction. This also includes the pre/post events. Now, if anybody would reload an unloaded object in the post event of a subtransaction, this would cause inconsistent state over the transaction hierarchy (an object being loaded in a subtransaction, but not in the parent transaction).
Therefore, fix the events as follows:
Raise all pre events first,
then make all changes,
then raise all post events.
This will make unload atomic over the transaction hierarchy: when any transacton in the hierarchy cancels the operation, nothing is unloaded from the other transactions.
At the same time, disable the transaction unlocking while these events are fired: the parent transactions should stay read-only while Unloading and Unloaded event handlers are running; otherwise, the handlers could break ClientTransaction state.