class PartialFilledStructureMerger {

    public IAtomContainer generate(IAtomContainerSet atomContainers) throws CDKException {
        int iteration = 0;
        boolean structureFound = false;
        do {
            iteration++;
            boolean bondFormed;
            do {
                bondFormed = false;
                for (IAtomContainer ac : atomContainers.atomContainers()) {
                    for (IAtom atom : AtomContainerManipulator.getAtomArray(ac)) {
                        if (!satCheck.isSaturated(atom, ac)) {
                            IAtom partner = getAnotherUnsaturatedNode(atom, ac, atomContainers);
                            if (partner != null) {
                                IAtomContainer toadd = AtomContainerSetManipulator.getRelevantAtomContainer(
                                        atomContainers, partner);
                                double cmax1 = satCheck.getCurrentMaxBondOrder(atom, ac);
                                double cmax2 = satCheck.getCurrentMaxBondOrder(partner, toadd);
                                double max = Math.min(cmax1, cmax2);
                                double order = Math.min(Math.max(1.0, max), 3.0);//(double)Math.round(Math.random() * max)
                                logger.debug("cmax1, cmax2, max, order: " + cmax1 + ", " + cmax2 + ", " + max + ", "
                                        + order);
                                if (toadd != ac) {
                                    atomContainers.removeAtomContainer(toadd);
                                    ac.add(toadd);
                                }
                                ac.addBond(ac.getBuilder().newInstance(IBond.class, atom, partner,
                                        BondManipulator.createBondOrder(order)));
                                bondFormed = true;
                            }
                        }
                    }
                }
            } while (bondFormed);
            if (atomContainers.getAtomContainerCount() == 1
                    && satCheck.allSaturated(atomContainers.getAtomContainer(0))) {
                structureFound = true;
            }
        } while (!structureFound && iteration < 5);
        if (atomContainers.getAtomContainerCount() == 1 && satCheck.allSaturated(atomContainers.getAtomContainer(0))) {
            structureFound = true;
        }
        if (!structureFound)
            throw new CDKException("Could not combine the fragments to combine a valid, satured structure");
        return atomContainers.getAtomContainer(0);
    }

    public  PartialFilledStructureMerger();

}