class Bundler::PubGrub::Incompatibility

def cleanup_terms(terms)

def cleanup_terms(terms)
  terms.each do |term|
    raise "#{term.inspect} must be a term" unless term.is_a?(Term)
  end
  if terms.length != 1 && ConflictCause === cause
    terms = terms.reject do |term|
      term.positive? && Package.root?(term.package)
    end
  end
  # Optimized simple cases
  return terms if terms.length <= 1
  return terms if terms.length == 2 && terms[0].package != terms[1].package
  terms.group_by(&:package).map do |package, common_terms|
    common_terms.inject do |acc, term|
      acc.intersect(term)
    end
  end
end