models/search: Build query trees