Avoid recursion for cycles.