Indexing tree-like structures