<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def undo_last_save(self, logMessage=None):
 """Undo the last change made to the datastream content and profile, effectively reverting to the object state in Fedora as of the specified timestamp. For a versioned datastream, this will purge the most recent datastream. For an unversioned datastream, this will overwrite the last changes with a cached version of any content and/or info pulled from Fedora. """

        # NOTE: currently not clearing any of the object caches and backups
        # of fedora content and datastream info, as it is unclear what (if anything)
        # should be cleared

        if self.versionable:
            # if this is a versioned datastream, get datastream history
            # and purge the most recent version
            last_save = self.history().versions[0].created  # fedora returns most recent first
            r = self.obj.api.purgeDatastream(self.obj.pid, self.id,
                                                datetime_to_fedoratime(last_save),
                                                logMessage=logMessage)
            return r.status_code == requests.codes.ok
        else:
            # for an unversioned datastream, update with any content and info
            # backups that were pulled from Fedora before any modifications were made
            args = {}
            if self._content_backup is not None:
                args['content'] = self._content_backup
            if self._info_backup is not None:
                args.update(self._info_backup)
            r = self.obj.api.modifyDatastream(self.obj.pid, self.id,
                            logMessage=logMessage, **args)
            return r.status_code == requests.codes.ok