def filter_invalid_permutations(permutations)
      valid = []
      permutations.each do |perm|
        versions = {}; invalid = false
        perm.each do |ref|
          if ref =~ /(.+)@(.+)/
            name, version = $1, $2
            if versions[name] && versions[name] != version
              invalid = true
              break
            else
              versions[name] = version
            end
          end
        end
        valid << perm.uniq unless invalid
      end

      valid
    end
def filter_invalid_permutations(permutations)
      valid = []
      permutations.each do |perm|
        versions = {}; invalid = false
        perm.each do |ref|
          if ref =~ /(.+)@(.+)/
            name, version = $1, $2
            if versions[name] && versions[name] != version
              invalid = true
              break
            else
              versions[name] = version
            end
          end
        end
        valid << perm.uniq unless invalid
      end

      valid
    end
Remove invalid permutations, that is permutations that contain multiple
 versions of the same package, a scenario which could arrive in the case of
 circular dependencies, or when different dependencies rely on different
 versions of the same transitive dependency.