Also, what about the case where a.b.example.com exists but doesn't
have an RR of the appropriate type, but there's a covering wildcard
with that RR type?
The premise of the algorithm (in RFC 1034) is that first you look for
a domain name (match the QNAME). From that either you find a match,
you fall back to a wild card, or NXDOMAIN. If you match at the
specific name, you forget the others. If the RR set you seek is not
at the specific name, you return "no data" and do not look for a wild
card entry.