Approach hintTry it first, then revealHide
Visit nodes in reverse preorder (right subtree, left subtree, node) while remembering the previously visited node; point each node's right child to it and clear the left child. A Morris-style loop needs O(1) space.