def has_loops(path):
    """Returns True if this path has a loop in it, i.e. if it
    visits a node more than once. Returns False otherwise."""
    visited = {}
    for node in path:
        if node not in visited:
            visited[node] = 0
        else:
            return True
    return False