<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def commit(self, session=None):
 """Merge modified objects into parent transaction. Once commited a transaction object is not usable anymore :param:session: current sqlalchemy Session """

        if self.__cleared:
            return

        if self._parent:
            # nested transaction
            self._commit_parent()
        else:
            self._commit_repository()
        self._clear()