docs: def add_transition_to_state(from_port, to_port):
      """Interface method between Gaphas and RAFCON core for adding transitions
  
      The method checks the types of the given ports (IncomeView or OutcomeView) and from this determines the necessary
      parameters for the add_transition method of the RAFCON core. Also the parent state is derived from the ports.
  
      :param from_port: Port from which the transition starts
      :param to_port: Port to which the transition goes to
      :return: True if a transition was added, False if an error occurred
      """
      from rafcon.gui.mygaphas.items.ports import IncomeView, OutcomeView
  
      from_state_v = from_port.parent
      to_state_v = to_port.parent
  
      from_state_m = from_state_v.model
      to_state_m = to_state_v.model
  
      # Gather necessary information to create transition
      from_state_id = from_state_m.state.state_id
      to_state_id = to_state_m.state.state_id
  
      responsible_parent_m = None
  
      # Start transition
      if isinstance(from_port, IncomeView):
          from_state_id = None
          from_outcome_id = None
          responsible_parent_m = from_state_m
          # Transition from parent income to child income
          if isinstance(to_port, IncomeView):
              to_outcome_id = None
          # Transition from parent income to parent outcome
          elif isinstance(to_port, OutcomeView):
              to_outcome_id = to_port.outcome_id
      elif isinstance(from_port, OutcomeView):
          from_outcome_id = from_port.outcome_id
          # Transition from child outcome to child income
          if isinstance(to_port, IncomeView):
              responsible_parent_m = from_state_m.parent
              to_outcome_id = None
          # Transition from child outcome to parent outcome
          elif isinstance(to_port, OutcomeView):
              responsible_parent_m = to_state_m
              to_outcome_id = to_port.outcome_id
      else:
          raise ValueError("Invalid port type")
  
      from rafcon.gui.models.container_state import ContainerStateModel
      if not responsible_parent_m:
          logger.error("Transitions only exist between incomes and outcomes. Given: {0} and {1}".format(type(
              from_port), type(to_port)))
          return False
      elif not isinstance(responsible_parent_m, ContainerStateModel):
          logger.error("Transitions only exist in container states (e.g. hierarchy states)")
          return False
  
      try:
          t_id = responsible_parent_m.state.add_transition(from_state_id, from_outcome_id, to_state_id, to_outcome_id)
          if from_state_id == to_state_id:
              gui_helper_meta_data.insert_self_transition_meta_data(responsible_parent_m.states[from_state_id], t_id,
                                                                    combined_action=True)
          return True
      except (ValueError, AttributeError, TypeError) as e:
          logger.error("Transition couldn't be added: {0}".format(e))
          return False