def get_flatcoo_position(findex, shape, findices):
    """Return the position of index in flattend COO indices. If index is
    not in indices, return None.
    """
    # binary search
    left = 0
    right = len(findices) - 1
    while left <= right:
        pos = (left + right) // 2
        d = findices[pos] - findex
        if d == 0:
            return pos
        if d < 0:
            left = pos + 1
        elif d > 0:
            right = pos - 1
    # findex is not in findices
    return