code: public static boolean compare(IMolecularFormula formula1, IMolecularFormula formula2) {
  
          if (!Objects.equals(formula1.getCharge(), formula2.getCharge())) return false;
  
          if (formula1.getIsotopeCount() != formula2.getIsotopeCount()) return false;
  
          for (IIsotope isotope : formula1.isotopes()) {
              if (!formula2.contains(isotope)) return false;
  
              if (formula1.getIsotopeCount(isotope) != formula2.getIsotopeCount(isotope)) return false;
  
          }
  
          for (IIsotope isotope : formula2.isotopes()) {
              if (!formula1.contains(isotope)) return false;
              if (formula2.getIsotopeCount(isotope) != formula1.getIsotopeCount(isotope)) return false;
          }
  
          return true;
      }
docs: Compare two IMolecularFormula looking at type and number of IIsotope and
  charge of the formula.
  
  @param formula1   The first IMolecularFormula
  @param formula2   The second IMolecularFormula
  @return           True, if the both IMolecularFormula are the same