Basically this code is checking if node being rotated is the root. If that is the case then the root is reassigned to be left child of previous root. If node being rotated isn't the root the and the node being rotated is a left child it is replaced with its own left child, if it is a right child the parent nodes right child is replaced with the nodes left child.
Then the parent of the nodes left child is assigned to be the nodes parent. Then the nodes parent is assigned as the nodes left child. Then the left child of the node is assigned to be the right child of the nodes left child. If the nodes left child is not null the parent of the nodes left child is assigned to be the node if nodes left child is null the nodes parents right child is set to be node.
Helpful?