code: def _do_tree_difference(a, b, parent_path, root=False):
      """Internal recursive worker function for tree_difference()."""
  
      # We do not want to list root node names.
      if root:
          assert not parent_path
          assert not a.is_file()
          assert not b.is_file()
          full_path = ""
      else:
          assert a.name == b.name
          full_path = parent_path + a.name
      result = TreeDifference()
  
      # A and B are both files.
      if a.is_file() and b.is_file():
          if a.contents != b.contents:
              result.modified_files.append(full_path)
          elif a.mtime != b.mtime:
              result.touched_files.append(full_path)
          return result
  
      # Directory converted to file.
      if not a.is_file() and b.is_file():
          result.removed_files.extend(_traverse_tree(a, parent_path))
          result.added_files.append(full_path)
  
      # File converted to directory.
      elif a.is_file() and not b.is_file():
          result.removed_files.append(full_path)
          result.added_files.extend(_traverse_tree(b, parent_path))
  
      # A and B are both directories.
      else:
          if full_path:
              full_path += "/"
          accounted_for = []  # Children present in both trees.
          for a_child in a.children:
              b_child = b.get_child(a_child.name)
              if b_child:
                  accounted_for.append(b_child)
                  result.append(
                      _do_tree_difference(a_child, b_child, full_path)
                  )
              else:
                  result.removed_files.append(full_path + a_child.name)
          for b_child in b.children:
              if b_child not in accounted_for:
                  result.added_files.extend(
                      _traverse_tree(b_child, full_path)
                  )
  
      return result
  
imports: import os
  import os.path
  import stat
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: _do_tree_difference(a, b, parent_path, root) and returns: result, result