Do not close the tree when (last) element is removed
### Describe the bug
When removing an element from a diagram that is not referenced it will be also removed from the model. This is 
an expected behavior. However, it also closes the tree, which is pretty annoying. In my opinion it might refresh the
tree, that's fine, but should not close it.

### To Reproduce
Steps to reproduce the behavior:
1. Create a diagram
2. Open the tree
3. Add an element
4. Select the element
5. Press delete button
6. Element will be removed, but also tree is closing

It seems that when also deleting an element in the tree it will close the tree as well. The two cases might or might not related.

### Expected behavior
Do not close the tree.

### OS
- [ ] Linux
- [ ] macOS
- [X] Windows

### Version
Version of Gaphor: main branch

diff --git a/gaphor/ui/tests/test_modelbrowser.py b/gaphor/ui/tests/test_modelbrowser.py
index a7839b17b..31d6e980a 100644
--- a/gaphor/ui/tests/test_modelbrowser.py
+++ b/gaphor/ui/tests/test_modelbrowser.py
@@ -288,6 +288,28 @@ def test_drop_multiple_elements(model_browser, element_factory, event_manager):
     assert class_a not in model_browser.get_selected_elements()
 
 
+def test_unlink_element_should_not_collapse_branch(
+    model_browser, element_factory, event_manager
+):
+    package = element_factory.create(UML.Package)
+    package.name = "p"
+    class_a = element_factory.create(UML.Class)
+    class_a.package = package
+    class_a.name = "a"
+    class_b = element_factory.create(UML.Class)
+    class_b.package = package
+    class_b.name = "b"
+
+    row0 = model_browser.selection.get_item(0)
+    row0.set_expanded(True)
+
+    class_a.unlink()
+
+    assert row0.get_item().element is package
+    assert row0.get_expanded()
+    assert model_browser.selection.get_item(1).get_item().element is class_b
+
+
 class MockRowItem:
     def __init__(self, list_item):
         self.list_item = list_item
diff --git a/gaphor/ui/treemodel.py b/gaphor/ui/treemodel.py
index cef69e73b..189db94a9 100644
--- a/gaphor/ui/treemodel.py
+++ b/gaphor/ui/treemodel.py
@@ -237,7 +237,10 @@ class TreeModel:
     def notify_child_model(self, element):
         # Only notify the change, the branch is created in child_model()
         owner_tree_item = self.tree_item_for_element(element.owner)
-        if (owner_branch := self.branches.get(owner_tree_item)) is not None:
+        if (
+            not self.branches.get(self.tree_item_for_element(element))
+            and (owner_branch := self.branches.get(owner_tree_item)) is not None
+        ):
             owner_branch.changed(element)
 
     def clear(self) -> None:
['gaphor/ui/tests/test_modelbrowser.py', 'gaphor/ui/treemodel.py']