<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_masters(self):
 """Update all `master` |Substituter| objects. If a |Substituter| object is passed to the constructor of another |Substituter| object, they become `master` and `slave`: True True During initialization, all mappings handled by the master object are passed to its new slave: |Node| :class:`~hydpy.core.devicetools.Node` |devicetools.Node| :class:`~hydpy.core.devicetools.Node` Updating a slave, does not affect its master directly: |HydPy| :class:`~hydpy.core.hydpytools.HydPy` |hydpytools.HydPy| :class:`~hydpy.core.hydpytools.HydPy` Through calling |Substituter.update_masters|, the `medium2long` mappings are passed from the slave to its master: |hydpytools.HydPy| :class:`~hydpy.core.hydpytools.HydPy` Then each master object updates its own master object also: |hydpytools.HydPy| :class:`~hydpy.core.hydpytools.HydPy` In reverse, subsequent updates of master objects to not affect their slaves directly: |Masks| :class:`~hydpy.core.masktools.Masks` |masktools.Masks| :class:`~hydpy.core.masktools.Masks` Through calling |Substituter.update_slaves|, the `medium2long` mappings are passed the master to all of its slaves: |masktools.Masks| :class:`~hydpy.core.masktools.Masks` |masktools.Masks| :class:`~hydpy.core.masktools.Masks` """

        if self.master is not None:
            self.master._medium2long.update(self._medium2long)
            self.master.update_masters()