static @Nullable Value lookupDocumentValue(Document document, String fieldPath) {
    OrderByFieldPath resolvedPath = OrderByFieldPath.fromString(fieldPath);
    // __name__ is a special field and doesn't exist in (top-level) valueMap (see
    // https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases.documents#Document).
    if (resolvedPath.isDocumentName()) {
      return Value.newBuilder().setReferenceValue(document.getName()).build();
    }
    return findMapValue(new ArrayList<>(resolvedPath.getSegments()), document.getFieldsMap());
  }
@Test
  public void lookupDocumentValue_nestedField() {
    assertEquals(
        QueryUtils.lookupDocumentValue(testDocument, "`fo\\`o.m\\`ap`.`bar.key`"),
        Value.newBuilder().setStringValue("bar.val").build());
  }