def METHOD_NAME(problem, tolerance=0.05, max_oversampling=201, plot=False):
    if plot:
        from matplotlib import pyplot as plt
    models = problem.models if hasattr(problem, 'models') else [problem]
    oversampling = []
    local_oversampling = []
    for i_model, model in enumerate(models):
        print("model: {:d}".format(i_model))
        oversampling_i = []
        local_oversampling_i = []
        oversampling.append(oversampling_i)
        local_oversampling.append(local_oversampling_i)
        fitness = model.fitness
        parts = fitness.parts if hasattr(fitness, 'parts') else [fitness]
        for i_part, part in enumerate(parts):
            # print(part)
            oversampling_ii, local_oversampling_ii, Q = get_optimal_single_oversampling(part, tolerance, max_oversampling)
            print("\tpart: {:d}, oversampling: {:d}".format(i_part, oversampling_ii))
            oversampling_i.append(oversampling_ii)
            local_oversampling_i.append(local_oversampling_ii)
            if plot:
                plt.figure()
                for i_oos, (oos, qq) in enumerate(zip(local_oversampling_ii, Q)):
                    if oos is not None:
                        plt.plot(qq, oos, label="xs: {:d}".format(i_oos))
                plt.title("model: {:d}, part: {:d}".format(i_model, i_part))
                plt.xlabel("Q (inv. A)")
                plt.ylabel("required oversampling")
                plt.legend()
        # there is one probe instance shared between parts in MixedExperiment: use
        # largest recommended oversampling.
        parts[0].probe.oversample(max(oversampling_i))
    if plot:
        plt.show()
    return oversampling, local_oversampling