docs: def insert_and_update_recursively(self, parent_iter, state_model, with_expand=False):
          """ Insert and/or update the handed state model in parent tree store element iterator
  
          :param parent_iter: Parent tree store iterator the insert should be performed in
          :param StateModel state_model: Model of state that has to be insert and/or updated
          :param bool with_expand: Trigger to expand tree
          :return:
          """
          # the case handling of this method
          # 0 - create - common state
          # 0.1 - modify attributes of common state which is already in the list
          # 1 - create - library with show content -> add library root state
          # 2 - create - library without show content -> add library state
          # 3 - in as library with show content -> switch library without show content, remove children + LibRootState
          # 3.1 - in as library with show content -> nothing to do
          # 4 - in as library without show content -> switch library with show content, add children + remove LibState
          # 4.1 - in as library without show content -> nothing to do
  
          # if state model is LibraryStateModel with enabled show content state_model becomes the library root state model
          if isinstance(state_model, LibraryStateModel) and self.show_content(state_model) and state_model.state_copy_initialized:
              _state_model = state_model
              state_model = state_model.state_copy
          else:
              _state_model = state_model
  
          if self._state_which_is_updated is None:
              self._state_which_is_updated = _state_model
  
          # TODO remove this workaround for removing LibraryStateModel or there root states by default
          if isinstance(_state_model, LibraryStateModel) and _state_model.state_copy_initialized:
              state_row_iter = None
              if _state_model.state.get_path() in self.state_row_iter_dict_by_state_path:
                  state_row_iter = self.state_row_iter_dict_by_state_path[_state_model.state.get_path()]
              if state_model.state.get_path() in self.state_row_iter_dict_by_state_path:
                  state_row_iter = self.state_row_iter_dict_by_state_path[state_model.state.get_path()]
  
              if state_row_iter:
                  self.remove_tree_children(state_row_iter)
                  del self.state_row_iter_dict_by_state_path[self.tree_store.get_value(state_row_iter, self.STATE_PATH_STORAGE_ID)]
                  self.tree_store.remove(state_row_iter)
  
          # if library root state is used instate of library state show both in type and state id
          _state_id = _state_model.state.state_id
          # _state_id += '' if _state_model is state_model else '/' + state_model.state.state_id  TODO enable this line
          _state_type = type(_state_model.state).__name__
          _state_type += '' if _state_model is state_model else '/' + type(state_model.state).__name__
  
          # check if in
          state_path = state_model.state.get_path()
          if state_path not in self.state_row_iter_dict_by_state_path:
              # if not in -> insert it
              state_row_iter = self.tree_store.insert_before(parent=parent_iter, sibling=None,
                                                             row=(state_model.state.name,
                                                                  _state_id,
                                                                  _state_type,
                                                                  _state_model,
                                                                  state_model.state.get_path()))
              self.state_row_iter_dict_by_state_path[state_path] = state_row_iter
              if with_expand:
                  parent_path = self.tree_store.get_path(state_row_iter)
                  self.view.expand_to_path(parent_path)
          else:
              # if in -> check if up to date
              state_row_iter = self.state_row_iter_dict_by_state_path[state_model.state.get_path()]
              self.update_tree_store_row(state_model)
  
          # check children
          # - check if ALL children are in
          if isinstance(state_model, ContainerStateModel):
              for child_state_id, child_state_model in state_model.states.items():
                  self.insert_and_update_recursively(state_row_iter, child_state_model, with_expand=False)
  
          # - check if TOO MUCH children are in
          # if state_model.state.get_library_root_state() is not None or isinstance(state_model, LibraryStateModel):
          for n in reversed(range(self.tree_store.iter_n_children(state_row_iter))):
              child_iter = self.tree_store.iter_nth_child(state_row_iter, n)
              child_state_path = self.tree_store.get_value(child_iter, self.STATE_PATH_STORAGE_ID)
              child_model = None
              if self._selected_sm_model.state_machine.get_state_by_path(child_state_path, as_check=True):
                  child_model = self._selected_sm_model.get_state_model_by_path(child_state_path)
              child_id = self.tree_store.get_value(child_iter, self.ID_STORAGE_ID)
  
              # check if there are left over rows of old states (switch from HS or CS to S and so on)
              show_content_flag = isinstance(child_model, LibraryStateModel) and self.show_content(child_model) and \
                                  child_model.state_copy_initialized
              child_is_lib_with_show_content = isinstance(child_model, LibraryStateModel) and show_content_flag
              child_is_lib_without_show_content = isinstance(child_model, LibraryStateModel) and not show_content_flag
  
              if not isinstance(state_model, ContainerStateModel) or child_model is None or \
                      child_id not in state_model.states and not child_is_lib_with_show_content \
                      and isinstance(child_model, LibraryStateModel) and child_id == child_model.state.state_copy.state_id \
                      or child_is_lib_without_show_content and child_id == child_model.state.state_copy.state_id or \
                      isinstance(_state_model, LibraryStateModel) and not self.show_content(_state_model) or \
                      child_model.state.is_root_state_of_library and not self.show_content(child_model.parent):
  
                  self.remove_tree_children(child_iter)
                  del self.state_row_iter_dict_by_state_path[self.tree_store.get_value(child_iter, self.STATE_PATH_STORAGE_ID)]
                  self.tree_store.remove(child_iter)
  
          if self._state_which_is_updated is _state_model:
              self._state_which_is_updated = None