public static Optional<RestartConfig.RestartNode> getNextNode(RestartConfig config) {
    if (config == null) {
      return Optional.empty();
    }
    List<RestartConfig.RestartNode> path = config.getRestartPath();
    if (path != null && path.size() > 1) {
      return Optional.of(path.get(path.size() - 2));
    }
    return Optional.empty();
  }
@Test
  public void testGetNextNode() {
    RestartConfig config = RestartConfig.builder().addRestartNode("foo", 1, "bar").build();
    Assert.assertEquals(Optional.empty(), RunRequest.getNextNode(config));
    config = config.toBuilder().addRestartNode("bar", 1, "bar").build();
    Assert.assertEquals(
        Optional.of(new RestartConfig.RestartNode("foo", 1, "bar")),
        RunRequest.getNextNode(config));
  }