docs: def add_data_flow_to_state(from_port, to_port):
      """Interface method between Gaphas and RAFCON core for adding data flows
  
      The method checks the types of the given ports and their relation. From this the necessary parameters for the
      add_dat_flow method of the RAFCON core are determined. Also the parent state is derived from the ports.
  
      :param from_port: Port from which the data flow starts
      :param to_port: Port to which the data flow goes to
      :return: True if a data flow was added, False if an error occurred
      """
      from rafcon.gui.mygaphas.items.ports import InputPortView, OutputPortView, ScopedVariablePortView
      from rafcon.gui.models.container_state import ContainerStateModel
  
      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
  
      from_state_id = from_state_m.state.state_id
      to_state_id = to_state_m.state.state_id
  
      from_port_id = from_port.port_id
      to_port_id = to_port.port_id
  
      if not isinstance(from_port, (InputPortView, OutputPortView, ScopedVariablePortView)) or \
              not isinstance(from_port, (InputPortView, OutputPortView, ScopedVariablePortView)):
          logger.error("Data flows only exist between data ports (input, output, scope). Given: {0} and {1}".format(type(
              from_port), type(to_port)))
          return False
  
      responsible_parent_m = None
  
      # from parent to child
      if isinstance(from_state_m, ContainerStateModel) and \
              check_if_dict_contains_object_reference_in_values(to_state_m.state, from_state_m.state.states):
          responsible_parent_m = from_state_m
      # from child to parent
      elif isinstance(to_state_m, ContainerStateModel) and \
              check_if_dict_contains_object_reference_in_values(from_state_m.state, to_state_m.state.states):
          responsible_parent_m = to_state_m
      # from parent to parent
      elif isinstance(from_state_m, ContainerStateModel) and from_state_m.state is to_state_m.state:
          responsible_parent_m = from_state_m  # == to_state_m
      # from child to child
      elif (not from_state_m.state.is_root_state) and (not to_state_m.state.is_root_state) \
              and from_state_m.state is not to_state_m.state \
              and from_state_m.parent.state.state_id and to_state_m.parent.state.state_id:
          responsible_parent_m = from_state_m.parent
  
      if not isinstance(responsible_parent_m, ContainerStateModel):
          logger.error("Data flows only exist in container states (e.g. hierarchy states)")
          return False
  
      try:
          responsible_parent_m.state.add_data_flow(from_state_id, from_port_id, to_state_id, to_port_id)
          return True
      except (ValueError, AttributeError, TypeError) as e:
          logger.error("Data flow couldn't be added: {0}".format(e))
          return False