def get_gradient_index(val, min_val, max_val, steps):
    """
    Returns the index in gradient given p-value, minimum value, maximum value
    and number of steps in gradient.
    
    >>> get_gradient_index(0.002, 0.001, 0.0029, 10)
    5
    >>> get_gradient_index(0.0011, 0.001, 0.0029, 10)
    0
    >>> get_gradient_index(0.002899999, 0.001, 0.0029, 10)
    9
    >>> get_gradient_index(0.0029, 0.001, 0.0029, 10)
    9
    >>> get_gradient_index(0.001, 0.001, 0.001, 10)
    0
    """
    if max_val == min_val:
        return 0
    else:
        d = (max_val - min_val) / steps
        r = int((val - min_val) / d)
        return r if r < steps else r - 1