<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_with(self, new_subsection):
 """ Replace this SubSection with new_subsection. Replacing SubSection must be the same time. That is, you can only replace a dmdSec with another dmdSec, or a rightsMD with a rightsMD etc. :param new_subsection: Updated version of this SubSection :type new_subsection: :class:`SubSection` """

        if self.subsection != new_subsection.subsection:
            raise exceptions.MetsError(
                "Must replace a SubSection with one of the same type."
            )
        # TODO convert this to a DB so have bidirectonal foreign keys??
        self.newer = new_subsection
        new_subsection.older = self
        self.status = None