Hierarchical data storage and retrieval