Joining Brep-Tiles via Connectivity

Hello forum!

I have here a special case, where I don’t have any idea, how to achieve it.

In short, I would like to do something like False Rectangle Packing by @laurent_delrieu (Great by the way!). But instead of drawing new rectangles, I would like to join pre-existing tiles in bigger squares ( but predefined sizes, like 2tiles x 2tiles , 3tiles x 3tiles , 4tiles x 4tiles).

I now that the answer lies in connectivity trees ( like from sandbox ) . But I am not sure, how to setup conditions for different sizes.
I tried it with anemone, and would love to solve it in python ( not a must ).

I hope you could understand my problem.

Thanks in advance!

greets,
Bumaye

the second image is edited with photoshop. I hope it clarifies my intention.

Hello
it is quite exactly what I am doing, if I remember well. The only problem is that you have no 1x1 tile. So by doing things randomly you could have some problems. It is doable by programmation. I have some C# example on this forum

thank you very much for the answer @laurent_delrieu!
I tried already your examples. Sadly, I have no idea about C#. How can I modify your script from your first suggestion, so that I only get squares ?
The main idea, is to use it on trimmed surfaces. I had the feeling that your examples only work with regular grids. In my case, I have tiles with different sizes ( it should be around 0.5, but not exactly).
Oh, and I forgot to mention, that I have also the 1tile x 1tile of course, to fill the gaps.

thank you very much!

You must post some files. Read this :

You have to learn to code. Grasshopper is programming but it is not very good for recursive problem like the one you have.
The closest script I have to your proble (connectivity of brep) is this