
See AVL tree, RedBlack tree 
If we write our tree nodes as (left subtree, nodevalue, right subtree), then the first structure is ((A, B, C), D, E), and the second is (A, B, (C, D, E)), and computing one from the other is very simple:
There are also "double left" and "double right" rotations, which can be written as compositions of left and right rotations. Tree rotations are used in AVL trees, RedBlack trees, splay trees, and others. 
D / \ / \ B E / \ A Ccan be rotated to look like
B / \ / \ A D / \ C E
This is called a right rotation. Going from the second tree to the first would be a left rotation.
If we write our tree nodes as (left subtree, nodevalue, right subtree), then the first structure is ((A, B, C), D, E), and the second is (A, B, (C, D, E)), and computing one from the other is very simple:
def right_rotation(treenode): left, D, E = treenode A, B, C = left return (A, B, (C, D, E))
There are also "double left" and "double right" rotations, which can be written as compositions of left and right rotations.
Tree rotations are used in AVL trees, RedBlack trees, splay trees, and others.
Reference: [this] page has some excelent (Free) java applets demonstrating tree rotations. (can we add applets to the Wiki?)