def update_models_recursively(state_m, expected=True):
    """ If a state model is reused the model depth maybe is to low. Therefore this method checks if all 
    library state models are created with reliable depth
    
    :param bool expected: Define newly generated library models as expected or triggers logger warnings if False
    """

    assert isinstance(state_m, AbstractStateModel)

    if isinstance(state_m, LibraryStateModel):
        if not state_m.state_copy_initialized:
            if not expected:
                logger.warning("State {0} generates unexpected missing state copy models.".format(state_m))
            state_m.recursive_generate_models(load_meta_data=False)
            import rafcon.gui.helpers.meta_data as gui_helper_meta_data
            gui_helper_meta_data.scale_library_content(state_m)

    if isinstance(state_m, ContainerStateModel):
        for child_state_m in state_m.states.values():
            update_models_recursively(child_state_m, expected)