I took a data structures course in university and I had to make an implementation of an avl tree in c which is a self balancing tree that uses rotations, so I basically have the code ready I just to go through your code, find how you insert new tree nodes and just merge the code and you'll be good to go.