parameters: (self, root)
return_statement: return iter_dfs(root, split)
docstring: :type root: Node
          :rtype: NodeCopy
docstring_summary: :type root: Node
          :rtype: NodeCopy
docstring_tokens: : type root : Node : rtype : NodeCopy
function: def copyRandomBinaryTree(self, root):
          """
          :type root: Node
          :rtype: NodeCopy
          """
          def iter_dfs(node, callback):
              result = None
              stk = [node]
              while stk:
                  node = stk.pop()
                  if not node:
                      continue
                  left_node, copy = callback(node)
                  if not result:
                      result = copy
                  stk.append(node.right)
                  stk.append(left_node)
              return result
      
          def merge(node):
              copy = NodeCopy(node.val)
              node.left, copy.left = copy, node.left
              return copy.left, copy
          
          def clone(node):
              copy = node.left
              node.left.random = node.random.left if node.random else None
              node.left.right = node.right.left if node.right else None
              return copy.left, copy
          
          def split(node):
              copy = node.left
              node.left, copy.left = copy.left, copy.left.left if copy.left else None
              return node.left, copy
      
          iter_dfs(root, merge)
          iter_dfs(root, clone)
          return iter_dfs(root, split)
function_tokens: def copyRandomBinaryTree ( self , root ) : def iter_dfs ( node , callback ) : result = None stk = [ node ] while stk : node = stk . pop ( ) if not node : continue left_node , copy = callback ( node ) if not result : result = copy stk . append ( node . right ) stk . append ( left_node ) return result def merge ( node ) : copy = NodeCopy ( node . val ) node . left , copy . left = copy , node . left return copy . left , copy def clone ( node ) : copy = node . left node . left . random = node . random . left if node . random else None node . left . right = node . right . left if node . right else None return copy . left , copy def split ( node ) : copy = node . left node . left , copy . left = copy . left , copy . left . left if copy . left else None return node . left , copy iter_dfs ( root , merge ) iter_dfs ( root , clone ) return iter_dfs ( root , split )