queries: add function to recover query name, pred pairs