class MolecularFormulaManipulator {

    public static IMolecularFormula getMostAbundant(IMolecularFormula mf) {
        final Isotopes isofact;
        try {
            isofact = Isotopes.getInstance();
        } catch (IOException e) {
            return null;
        }
        IMolecularFormula res = mf.getBuilder()
                                  .newInstance(IMolecularFormula.class);
        for (IIsotope iso : mf.isotopes()) {
            int count = mf.getIsotopeCount(iso);
            if (iso.getMassNumber() == null || iso.getMassNumber() == 0) {
                IIsotope[] isotopes = isofact.getIsotopes(iso.getSymbol());
                Arrays.sort(isotopes, NAT_ABUN_COMP);
                if (!addIsotopeDist(res, isotopes, 0, count))
                    return null;
            } else
                res.addIsotope(iso, count);
        }
        return res;
    }

}