The treeview control is always a bit difficult, I remember my first contact with Gtk.TreeView and it wasn’t straightforward but the behaviour of WPF Treeview is still weird for me.
Basicly if you use a HierarchicalDataTemplate you won’t be able to manage the TreeViewItems programmatically so better you create the whole treeview programmatically.
In order to go through the items in the tree, the LogicalTreeHelper and the VisualTreeHelper are very important classes. They are key classes for XAML in general.
The links below has been very useful to undertand that:

As you can read in the posts, to find out what item in the TreeView is at the position where the ContextMenu was opened, you should populate the tree with TreeViewItems, not with the HierarchicalDataTemplate.
When populating the treeview with TreeViewItems, use the Header property to attach the objects you really want to show in the tree. As usual, override the ToString property in such objects to display the desired content 😉