public List<Node> writeTo(Node.State toState, List<Node> nodes,
                              Agent agent, Optional<String> reason) {
        try (NestedTransaction nestedTransaction = new NestedTransaction()) {
            List<Node> writtenNodes = writeTo(toState, nodes, agent, reason, nestedTransaction);
            nestedTransaction.commit();
            return writtenNodes;
        }
    }
Writes the given nodes to the given state (whether they are already in this state or another),
and returns a copy of the incoming nodes in their persisted state.

@param  toState the state to write the nodes to
@param  nodes the list of nodes to write
@param  agent the agent causing this change
@return the nodes in their persisted state
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java