When deploying solutions, you can’t include Business Units in your solution file and if you are needing to create many of them, this can be a bit of a hassle.
I recently had this problem where I was working on a project that had many units that I didn’t want to create manually, so I turned my eyes to the SDK in order to take this task from 20 minutes to 1.
The Parent Business Unit
The most important thing with Business Units is to remember their hierarchy. Irrespective of how you have setup your system, you will always have a top-level unit that everything else inherits from.
When trying to find this unit (to then extend from) all you need to do is query for the businessunit that does not have a parent