def _BisectHashList(ls, left, right, value):
  """Select the server that allocates 'value' using a binary search."""
  if right < left:
    return None
  if left == right:
    return ls[left]
  middle = left + (right - left) / 2
  middleval = ls[middle]
  start = middleval.interval.start
  end = middleval.interval.end
  if start <= value < end:
    return middleval
  if value >= end:
    return _BisectHashList(ls, middle + 1, right, value)
  if value < start:
    return _BisectHashList(ls, left, middle - 1, value)