Find cycles in a list