Remove a tag's class instance if it isn't used anymore

After removing a tag from a treenode, it is now tested whether the tag is still
linked to another treenode. If it isn't, it is removed (i.e. it's class instance
is removed). This fixes #422.