public static IAtom GetMostElectronegativeAtom(this IAtomContainer mol) { if (mol == null || !mol.Atoms.Any() || !mol.Bonds.Any()) { return(null); } IAtom atomOut = null; foreach (var bond in mol.Bonds) { var contender = bond.GetMostElectronegativeAtom(); var num = contender?.Electronegativity() ?? 0D; var cur = atomOut?.Electronegativity() ?? 0D; if (num > cur) { atomOut = contender; } } return(atomOut); }