def GetCommonPrefixLength(list1, list2):
  """Returns the length of the common prefix between two lists.

  Args:
    list1: the first list.
    list2: the second list.

  Returns:
    the highest n such as list1[:n] == list2[:n]
  """
  l = min(len(list1), len(list2))
  for i in range(0, l):
    if list1[i] != list2[i]: return i
  return l