<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def previous_version(self, object, relations_as_of='end'):
 """ Return the previous version of the given object. In case there is no previous object existing, meaning the given object is the first version of the object, then the function returns this version. ``relations_as_of`` is used to fix the point in time for the version; this affects which related objects are returned when querying for object relations. See ``VersionManager.version_as_of`` for details on valid ``relations_as_of`` values. :param Versionable object: object whose previous version will be returned. :param mixed relations_as_of: determines point in time used to access relations. 'start'|'end'|datetime|None :return: Versionable """

        if object.version_birth_date == object.version_start_date:
            previous = object
        else:
            previous = self.filter(
                Q(identity=object.identity),
                Q(version_end_date__lte=object.version_start_date)
            ).order_by('-version_end_date').first()

            if not previous:
                raise ObjectDoesNotExist(
                    "previous_version couldn't find a previous version of "
                    "object " + str(object.identity))

        return self.adjust_version_as_of(previous, relations_as_of)