def _hill_valley_test(obj, x, xn, Nt):
    """
    Test if a point `x` and its neighbor `xn` belongs to the same niche based on a Hill-Valley test approach

    Parameters
    ----------
    obj : callable
        Objective function.
    x : array_like, shape (n,)
        Point.
    xn : array_like, shape (n,)
        Neighboring point.
    Nt : int
        Number of test points.

    Returns
    -------
    test : bool
        True if `x` and `xn` belongs to the same niche, otherwise false.
    """

    fmax = max(obj(x), obj(xn))

    for i in range(1, Nt + 1):
        xt = xn + i / (Nt + 1) * (x - xn)
        if fmax < obj(xt):
            return False

    return True