Fix positioning algorithm

Fix positioning algorithm to balance branches on each level