class ErrorMap {

    static Optional<String> tryLookingUp(final JsonNode node, final String... pathElements) {
        JsonNode current = node;
        for (String pathElement : pathElements) {
            current = current.get(pathElement);

            if (current != null && current.isArray() && current.iterator().hasNext()) {
                current = current.iterator().next();
            }

            if (current == null) {
                return Optional.empty();
            }
        }

        if (current.isObject()) {
            return Optional.of(current.toString());
        }

        return Optional.of(current.asText());
    }

    private  ErrorMap();

}