How to get the collection an object belongs to?
Object.users_collection property returns a tuple containing all linked collections:

&gt;&gt;&gt; obj = bpy.context.object
&gt;&gt;&gt; obj.users_collection
(bpy.data.collections['Collection'],)