Fixed DFS for cycleCount