The Blender 2.8 Python API allows me to retrieve all child collections of a collection using its children property. Given the following collection hierarchy
+------------------+
| Scene Collection |
+------------------+
|
| +---+
+--| a |
+---+
|
| +---+
+--| b |
| +---+
| |
| |
| | +---+
| +--| c |
| | +---+
| |
| | +---+
| +--| d |
| +---+
|
| +---+
+--| e |
+---+
I can access the children of collection b (i.e. collections c and d) using the following code:
collection_b = bpy.data.collections['b']
children = collection_b.children
That way I can navigate down the collection tree. My question is how I can navigate upwards, i.e. how can I get the parent collection of say collection b?
I didn't find a property allowing me to retrieve the parent collection(s).
Essentially I'm interested in recursively making my way up all to the root (Scene Collection), e.g
d -> b -> a -> Scene Collection

bpy.data.objects['Cylinder'].users_collectionSource: https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.users_collection – sleepystar96 Mar 12 '22 at 14:37users_collectionto get the parent collection, so it's likely doing this iteration logic for you. – sleepystar96 Mar 12 '22 at 14:39