def get_state_id_for_port(port):
    """This method returns the state ID of the state containing the given port

    :param port: Port to check for containing state ID
    :return: State ID of state containing port
    """
    parent = port.parent
    from rafcon.gui.mygaphas.items.state import StateView
    if isinstance(parent, StateView):
        return parent.model.state.state_id
