<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def overlay_images(self, canvas, data, whence=0.0):
 """Overlay data from any canvas image objects. Parameters canvas : `~ginga.canvas.types.layer.DrawingCanvas` Canvas containing possible images to overlay. data : ndarray Output array on which to overlay image data. whence See :meth:`get_rgb_object`. """

        #if not canvas.is_compound():
        if not hasattr(canvas, 'objects'):
            return

        for obj in canvas.get_objects():
            if hasattr(obj, 'draw_image'):
                obj.draw_image(self, data, whence=whence)
            elif obj.is_compound() and (obj != canvas):
                self.overlay_images(obj, data, whence=whence)