def squash_old_versions
      specifiers = map_specifiers_to_versions

      compare_versions = lambda do |x, y|
        v_x = x =~ Lyp::PACKAGE_RE && Lyp.version($2)
        v_y = y =~ Lyp::PACKAGE_RE && Lyp.version($2)
        x <=> y
      end

      specifiers.each do |package, clauses|
        # Remove old versions only if the package is referenced using a single
        # specifier clause
        next unless clauses.size == 1

        specs = clauses.values.first
        specs.each do |s|
          if s.versions.values.uniq.size == 1
            versions = s.versions.keys.sort(&compare_versions)
            latest = versions.last
            s.versions.select! {|k, v| k == latest}
          end
        end
      end
    end
def squash_old_versions
      specifiers = map_specifiers_to_versions

      compare_versions = lambda do |x, y|
        v_x = x =~ Lyp::PACKAGE_RE && Lyp.version($2)
        v_y = y =~ Lyp::PACKAGE_RE && Lyp.version($2)
        x <=> y
      end

      specifiers.each do |package, clauses|
        # Remove old versions only if the package is referenced using a single
        # specifier clause
        next unless clauses.size == 1

        specs = clauses.values.first
        specs.each do |s|
          if s.versions.values.uniq.size == 1
            versions = s.versions.keys.sort(&compare_versions)
            latest = versions.last
            s.versions.select! {|k, v| k == latest}
          end
        end
      end
    end
Remove redundant older versions of dependencies by collating package
 versions by package specifiers, then removing older versions for any
 package for which a single package specifier exists.