/** * Calculates the intersection of two FieldMasks. */ public static FieldMask intersection(FieldMask mask1, FieldMask mask2) { FieldMaskTree tree = new FieldMaskTree(mask1); FieldMaskTree result = new FieldMaskTree(); for (String path : mask2.getPathsList()) { tree.intersectFieldPath(path, result); } return result.toFieldMask(); }