in http-core/src/main/scala/com/twitter/finatra/http/jsonpatch/JsonPatchOperator.scala [189:201]
private def safeGetNode(path: JsonPointer, target: JsonNode, operation: String): JsonNode = {
if (path.tail == null) {
throw new JsonPatchException(s"invalid path for $operation operation")
} else if (path.tail.matches) {
target match {
case on: ObjectNode => on.get(path.getMatchingProperty)
case an: ArrayNode => an.get(getLeafIndex(path, an, operation))
case _ => throw new JsonPatchException(s"invalid target for $operation operation")
}
} else {
safeGetNode(path.tail, nextNodeByPath(path, target, operation), operation)
}
}