Ex: for attributes, we could assume that, if the top item on the stack isn't an HTMLElement subtype, we should use the handle DOM node instead. Or we could check for the handle of the stack.
Generics would work well here. We could have a generic for a subtype of HTMLElement, a generic for a handle, and a fallback that explains that the given combinator was expecting one or the other.