Another solution is you give a key to the HierarchicalDataTemplate and put it in the Windows.Resources, and manually reference to it in the TreeView.
But that limits the autoselection of data template according to data type, which is provided by WPF TreeView.