<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _filter_library_state(self, items):
 """Filters out child elements of library state when they cannot be hovered Checks if hovered item is within a LibraryState * if not, the list is returned unfiltered * if so, STATE_SELECTION_INSIDE_LIBRARY_STATE_ENABLED is checked * if enabled, the library is selected (instead of the state copy) * if not, the upper most library is selected :param list items: Sorted list of items beneath the cursor :return: filtered items :rtype: list """

        if not items:
            return items

        top_most_item = items[0]
        # If the hovered item is e.g. a connection, we need to get the parental state
        top_most_state_v = top_most_item if isinstance(top_most_item, StateView) else top_most_item.parent
        state = top_most_state_v.model.state

        global_gui_config = gui_helper_state_machine.global_gui_config
        if global_gui_config.get_config_value('STATE_SELECTION_INSIDE_LIBRARY_STATE_ENABLED'):
            # select the library state instead of the library_root_state because it is hidden
            if state.is_root_state_of_library:
                new_topmost_item = self.view.canvas.get_view_for_core_element(state.parent)
                return self.dismiss_upper_items(items, new_topmost_item)
            return items
        else:
            # Find state_copy of uppermost LibraryState
            library_root_state = state.get_uppermost_library_root_state()

            # If the hovered element is a child of a library, make the library the hovered_item
            if library_root_state:
                library_state = library_root_state.parent
                library_state_v = self.view.canvas.get_view_for_core_element(library_state)
                return self.dismiss_upper_items(items, library_state_v)
            return items