function isOneofGroup(any) {
    if (typeof any != 'object' || any === null || !any.hasOwnProperty('oneofKind')) {
        return false;
    }
    switch (typeof any.oneofKind) {
        case "string":
            if (any[any.oneofKind] === undefined)
                return false;
            return Object.keys(any).length == 2;
        case "undefined":
            return Object.keys(any).length == 1;
        default:
            return false;
    }
}
Is the given value a valid oneof group?

We represent protobuf `oneof` as algebraic data types (ADT) in generated
code. But when working with messages of unknown type, the ADT does not
help us.

This type guard checks if the given object adheres to the ADT rules, which
are as follows:

1) Must be an object.

2) Must have a "oneofKind" discriminator property.

3) If "oneofKind" is `undefined`, no member field is selected. The object
must not have any other properties.

4) If "oneofKind" is a `string`, the member field with this name is
selected.

5) If a member field is selected, the object must have a second property
with this name. The property must not be `undefined`.

6) No extra properties are allowed. The object has either one property
(no selection) or two properties (selection).