Given a TreeNode defined with an additional parent pointer, print all nodes of a given tree in any order using constant space. You are not allowed to modify the tree structure itself.
class TreeNode
{
public int val;
public TreeNode left;
public TreeNode right;
public TreeNode parent;
public TreeNode(int x) { val = x; }
}