minRotate function

Rotates all nodes of the tree to minimize the difference in order with a vector