tree: optimize lookups