Query Reasoning on Trees with Types, Interleaving, and Counting