Python: Expanding Complicated Tree DataStructure
问题 I am exploring a data structure which get expands to sub-elements and resolves to a final element. But I only want to store top two levels. Example: Lets say I start with New York which breaks into Bronx, Kings, New York, Queens, and Richmond as counties but then finally somehow they resolve to USA. I am not sure if this is a good example but just to make it clear here is more clear explanation of the problem. A (expands to) B,C,D -> B (expands to) K,L,M -> K resolves to Z I initially wrote