Binary tree rotations
Haskell, 93 92 84 83 82 bytes



data B=B[B]Int|L
k!B[l@(B[x,y]a),r]n|k&lt;n=B[k!l,r]n|k&gt;n=B[l,k!r]n|1&gt;0=B[x,B[y,r]k]a


Thanks to @BMO, @alephalpha and @Laikoni for a byte each and @nimi for eight bytes!

Try it online!