Implemented branch switching

Keeping the smallest branches closest to the center to make the tree
less zig-zaggy.
Added documentation and compiled into an R-package.
Merge branch 'develop'