<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_momentum_by_name(self, name):
 """Gets a momentum by the given name. :param name: the momentum name. :returns: a momentum found. :raises TypeError: `name` is ``None``. :raises KeyError: failed to find a momentum named `name`. """

        if name is None:
            raise TypeError('\'name\' should not be None')
        for momentum in self.momenta:
            if momentum.name == name:
                return momentum
        raise KeyError('No such momentum named {0}'.format(name))