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