function resolveElement(val) {
    if (val instanceof Element) {
        return val;
    } else if (typeof val === 'string') {
        return val.split(/>>/g).reduce((pv, cv, ci, a) => {
            pv = pv.querySelector(cv);
            return ci < a.length - 1 ? pv.shadowRoot : pv;
        }, document);
    }

    return null;
}
Resolves a HTMLElement by query.
@param val
@returns {null|Document|Element}