class DoubleBondAcceptingAromaticityDetector {

    public static boolean detectAromaticity(IAtomContainer atomContainer) throws CDKException {
        SpanningTree spanningTree = new SpanningTree(atomContainer);
        IAtomContainer ringSystems = spanningTree.getCyclicFragmentsContainer();
        if (ringSystems.getAtomCount() == 0) {
            // If there are no rings, then there cannot be any aromaticity
            return false;
        }
        // disregard all atoms we know that cannot be aromatic anyway
        for (IAtom atom : ringSystems.atoms())
            if (!atomIsPotentiallyAromatic(atom)) ringSystems.removeAtom(atom);

        // FIXME: should not really mark them here
        Iterator<IAtom> atoms = ringSystems.atoms().iterator();
        while (atoms.hasNext())
            atoms.next().setFlag(CDKConstants.ISINRING, true);
        Iterator<IBond> bonds = ringSystems.bonds().iterator();
        while (bonds.hasNext())
            bonds.next().setFlag(CDKConstants.ISINRING, true);

        boolean foundSomeAromaticity = false;
        Iterator<IAtomContainer> isolatedRingSystems = ConnectivityChecker.partitionIntoMolecules(ringSystems)
                .atomContainers().iterator();
        while (isolatedRingSystems.hasNext()) {
            IAtomContainer isolatedSystem = isolatedRingSystems.next();
            IRingSet singleRings = Cycles.sssr(isolatedSystem).toRingSet();
            Iterator<IAtomContainer> singleRingsIterator = singleRings.atomContainers().iterator();
            int maxRingSize = 20;
            boolean allRingsAreAromatic = true;
            // test single rings in SSSR
            while (singleRingsIterator.hasNext()) {
                IAtomContainer singleRing = singleRingsIterator.next();
                if (singleRing.getAtomCount() > maxRingSize) maxRingSize = singleRing.getAtomCount();
                // possibly aromatic
                boolean ringIsAromatic = isHueckelValid(singleRing);
                foundSomeAromaticity |= ringIsAromatic;
                allRingsAreAromatic &= ringIsAromatic;
                if (ringIsAromatic) markRingAtomsAndBondsAromatic(singleRing);
            }
            // OK, what about the one larger ring (if no aromaticity found in SSSR)?
            if (!allRingsAreAromatic && singleRings.getAtomContainerCount() <= 3) {
                // every ring system consisting of more than two rings is too difficult
                Iterator<IAtomContainer> allRingsIterator = new AllRingsFinder()
                        .findAllRingsInIsolatedRingSystem(isolatedSystem).atomContainers().iterator();
                while (allRingsIterator.hasNext()) {
                    // there should be exactly three rings, of which only one has a size larger
                    // than the two previous ones
                    IAtomContainer ring = allRingsIterator.next();
                    if (ring.getAtomCount() <= maxRingSize) {
                        // possibly aromatic
                        boolean ringIsAromatic = isHueckelValid(ring);
                        foundSomeAromaticity |= ringIsAromatic;
                        if (ringIsAromatic) markRingAtomsAndBondsAromatic(ring);
                    }
                }
            }
        }

        return foundSomeAromaticity;
    }

}