def request_tree(point, kd_tree, nb_neighbors=None, radius=None):
    """Extract a point neighborhood by the way of a KDTree method

    At least one parameter amongst 'nb_neighbors' and 'radius' much be
    valid. 'nb_neighbors' is considered first.

    Parameters
    ----------
    point : numpy.array
        Coordinates of the reference point (x, y, z)
    tree : scipy.spatial.KDTree
        Tree representation of the point cloud
    nb_neighbors : int
        Number of neighboring points to consider
    radius : float
        Radius that defines the neighboring ball around a given point

    Returns
    -------
    tuple
        Neighborhood, decomposed as a mean distance between the reference point
    and its neighbors and an array of neighbor indices within the point
    cloud. Get `nb_neighborhood + 1` in order to have the reference point and
    its k neighbors. If the neighborhood is recovered through radius, distances
    are not computed.
    """
    if nb_neighbors is not None:
        return kd_tree.query(point, k=nb_neighbors + 1)
    if radius is not None:
        return None, kd_tree.query_ball_point(point, r=radius)
    raise ValueError(
        "Kd-tree request error: nb_neighbors and radius can't be both None.")
