def find_first_visited_twice(visited_order):
    """Find first position that repeats in visited_order."""
    visited = set()
    for location in visited_order:
        if location in visited:
            return location
        visited.add(location)
    return None