resolve = function (anchorType, json) {
    if (json === null) {
        return null;
    }

    const result = {};

    for (const [key, val] of Object.entries(json)) {
        if (val instanceof HassAnchor) {
            if (val.getType() !== anchorType) {
                throw new Error("Wrong anchor type! Expecting " + anchorType + ", found " + val.getType());
            }

            const anchorVal = val.getValue();
            if (anchorVal === null) {
                return null;
            }

            result[key] = anchorVal;

        } else if (!(val instanceof Array) && val instanceof Object) {
            const nested = resolve(anchorType, val);
            if (nested === null) {
                return null;
            }

            result[key] = nested;
        } else {
            result[key] = val;
        }
    }

    return result;
}
@private
@static
@param {string} anchorType
@param {object} json
@return {object|null}