How can I make a random generated map?

Hello.
I’m trying to make a random generated map, more specifically I have 4 blueprints, each of them has a static mesh component - a room with different number of doors, from 1 to 4.
Right now I have something like this in every room blueprint:

But this leads to an infinite loop.
I was thinking about a specific number of rooms per level. So in the level blueprint I could have a variable, specifying how many rooms to spawn and each time a room would spawn the variable would deincrement, but I’m not sure how to synchronize everything.
I probably would manage this in C++, but I prefer this entire system in blueprint form.