<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_state_for_transition(self, transition):
 """Calculate the target state of a transition :param transition: The transition of which the target state is determined :return: the to-state of the transition :raises exceptions.TypeError: if the transition parameter is of wrong type """

        if not isinstance(transition, Transition):
            raise TypeError("transition must be of type Transition")
        # the to_state is None when the transition connects an outcome of a child state to the outcome of a parent state
        if transition.to_state == self.state_id or transition.to_state is None:
            return self
        else:
            return self.states[transition.to_state]