Separate a tool.getsurroundingselements list

Hi

I want to create a list of rooms and the windows inside of the rooms. I am using the tool.getsurroundingelements to get a list of rooms and the windows.
My issue is that if I have multiple windows inside the same room I want to separate it to a new sublist, so instead of [room, window1, window 2] it should be: [room, window 1];[room, window 2]. I have made a python script that looks for the word room and then separates the list, but since the rooms are objects I can’t search for it inside of the list by only using “Room”.

One option is to change the rooms to strings instead, but in that way, I lose all of the information I have about my room and I cant extract the room number afterwards. Is there some way I can change the string to objects afterwards?

BR Nicolai