If this node is right child of its parent , visit parent 's parent first
while root . parent and root == root . parent . right : NEW_LINE INDENT root = root . parent NEW_LINE DEDENT if root . parent == None : NEW_LINE INDENT break NEW_LINE DEDENT root = root . parent NEW_LINE else : NEW_LINE break NEW_LINE