def _get_index(x, x_levels):
    """Finds element in list and returns index.

    Parameters
    ----------
    x: float
        Element to be searched.
    x_levels: list
        List for searching.

    Returns
    -------
    i: int
        Index for the value.

    """
    for i, value in enumerate(x_levels):
        if i < len(x_levels) and value < x:
            pass
        elif x == value:
            return i
        else:
            return i - 1