def METHOD_NAME(self, name, backing, depth):
    def _is_backing_exit(backing, depth):
        if isinstance(backing, dict) and "backing" in backing.keys():
            depth -= 1
            if depth != 0:
                backing = _is_backing_exit(backing["backing"], depth)
        return backing
    backing = _is_backing_exit(backing, depth)
    image = self.get_image_by_tag(name)
    filename = image.image_filename
    is_cor = backing["driver"] == "copy-on-read"
    opts = backing["file"]["file"] if is_cor else backing["file"]
    file_opts = qemu_storage.filename_to_file_opts(filename)
    if not self._is_same_file(opts, file_opts):
        self.test.fail("file %s not in backing" % filename)