import bisect


def find_min_revision_index(revisions_list, revision):
  """Find the min index for bisection. Find largest revision <= the given
  revision."""
  # bisect_left partitions |revisions_list| into 2 such that:
  #   all(val < revision for val in a[:index])
  #   all(val >= revision for val in a[index:])
  index = bisect.bisect_left(revisions_list, revision)
  if index < len(revisions_list) and revisions_list[index] == revision:
    return index

  if index > 0:
    return index - 1

  # No revisions <= given revision.
  return None