# File lib/kwala/lib/cycle_detector.rb, line 195
  def unique_cycles(cycles)
    uniq = Hash.new

    cycles.each do |cycle|
      uf = Hash.new
      cycle.each_with_index do |p, i|
        if uf.key?(p)
          # only add new cycles
          if !uniq.key?(p)
            cyc = cycle[uf[p] .. -1]
            uniq[p] = cyc
          end
        else
          uf[p] = i
        end
      end
    end

    uniq.values
  end