'Returns the new node after taking the action action. Stays at the current
node if the action is invalid.'

def take_action(self, current_node_ids, action):

    (actions, next_node_ids) = self.get_feasible_actions(current_node_ids)
    new_node_ids = []
    for (i, (c, a)) in enumerate(zip(current_node_ids, action)):
        if (actions[(i, a)] == 1):
            new_node_ids.append(next_node_ids[i][a])
        else:
            new_node_ids.append(c)
    return new_node_ids
