added a function to distribute the work appropriate to the processes based on a tree structure. Tests will be added soon.