# Buggy code
def _find_compositor(
    self, dataset_key, calibration=None, polarization=None, resolution=None
):
    """Find the compositor object for the given dataset_key."""
    # NOTE: This function can not find a modifier that performs one or more modifications
    # if it has modifiers see if we can find the unmodified version first
    src_node = None
    if isinstance(dataset_key, DatasetID) and dataset_key.modifiers:
        new_prereq = DatasetID(*dataset_key[:-1] + (dataset_key.modifiers[:-1],))
        src_node, u = self._find_dependencies(
            new_prereq, calibration, polarization, resolution
        )
        if u:
            return None, u

    try:
        compositor = self.get_compositor(dataset_key)
    except KeyError:
        raise KeyError("Can't find anything called {}".format(str(dataset_key)))
    if resolution:
        compositor.info["resolution"] = resolution
    if calibration:
        compositor.info["calibration"] = calibration
    if polarization:
        compositor.info["polarization"] = polarization
    dataset_key = compositor.id
    # 2.1 get the prerequisites
    prereqs, unknowns = self._get_compositor_prereqs(
        compositor.info["prerequisites"],
        calibration=calibration,
        polarization=polarization,
        resolution=resolution,
    )
    if unknowns:
        return None, unknowns

    optional_prereqs, _ = self._get_compositor_prereqs(
        compositor.info["optional_prerequisites"],
        skip=True,
        calibration=calibration,
        polarization=polarization,
        resolution=resolution,
    )

    # Is this the right place for that?
    if src_node is not None:
        prereqs.insert(0, src_node)
    root = Node(dataset_key, data=(compositor, prereqs, optional_prereqs))
    # LOG.debug("Found composite {}".format(str(dataset_key)))
    for prereq in prereqs + optional_prereqs:
        if prereq is not None:
            self.add_child(root, prereq)

    return root, set()


# Traceback (AttributeError)
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] Saving datasets to NetCDF4/CF.
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] No longitude and latitude data to save.
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] No grid mapping to save.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-24-58ece08c15f3> in <module>()
----> 1 lcl.save_datasets(writer='cf', filename='/tmp/foo.nc')

/home/lahtinep/Software/pytroll/packages/satpy/satpy/scene.pyc in save_datasets(self, writer, datasets, **kwargs)
632             datasets = self.datasets.values()
633         writer = self.get_writer(writer, **kwargs)
--> 634         writer.save_datasets(datasets, **kwargs)
635
636     def get_writer(self, writer="geotiff", **kwargs):

/home/lahtinep/Software/pytroll/packages/satpy/satpy/writers/cf_writer.pyc in save_datasets(self, datasets, filename, **kwargs)
176                     coords = [line_coord, pixel_coord]
177
--> 178                 domain = cf.Domain(dim=coords,
179                                    aux=aux,
180                                    ref=grid_mapping)

AttributeError: 'module' object has no attribute 'Domain'

# Fixed code
def _find_compositor(
    self, dataset_key, calibration=None, polarization=None, resolution=None
):
    """Find the compositor object for the given dataset_key."""
    # NOTE: This function can not find a modifier that performs one or more modifications
    # if it has modifiers see if we can find the unmodified version first
    src_node = None
    if isinstance(dataset_key, DatasetID) and dataset_key.modifiers:
        new_prereq = DatasetID(*dataset_key[:-1] + (dataset_key.modifiers[:-1],))
        src_node, u = self._find_dependencies(
            new_prereq, calibration, polarization, resolution
        )
        if u:
            return None, u

    try:
        compositor = self.get_compositor(dataset_key)
    except KeyError:
        raise KeyError("Can't find anything called {}".format(str(dataset_key)))
    if resolution:
        compositor.attrs["resolution"] = resolution
    if calibration:
        compositor.attrs["calibration"] = calibration
    if polarization:
        compositor.attrs["polarization"] = polarization
    dataset_key = compositor.id
    # 2.1 get the prerequisites
    prereqs, unknowns = self._get_compositor_prereqs(
        compositor.attrs["prerequisites"],
        calibration=calibration,
        polarization=polarization,
        resolution=resolution,
    )
    if unknowns:
        return None, unknowns

    optional_prereqs, _ = self._get_compositor_prereqs(
        compositor.attrs["optional_prerequisites"],
        skip=True,
        calibration=calibration,
        polarization=polarization,
        resolution=resolution,
    )

    # Is this the right place for that?
    if src_node is not None:
        prereqs.insert(0, src_node)
    root = Node(dataset_key, data=(compositor, prereqs, optional_prereqs))
    # LOG.debug("Found composite {}".format(str(dataset_key)))
    for prereq in prereqs + optional_prereqs:
        if prereq is not None:
            self.add_child(root, prereq)

    return root, set()