def add_prep(nodes, oldnodes=nil)
      if oldnodes
        oldnodes = oldnodes.map{|n| n.object_id}
        nodes.map! do |node|
          if node.attached? && oldnodes.delete(node.object_id).nil?
            node = node.clone
          end
          set_parent node, self
          node
        end
      else
        nodes.map! do |node|
          node = node.clone if node.attached?
          set_parent node, self
          node
        end
      end
      return nodes
    end
def add_prep(nodes, oldnodes=nil)
      if oldnodes
        oldnodes = oldnodes.map{|n| n.object_id}
        nodes.map! do |node|
          if node.attached? && oldnodes.delete(node.object_id).nil?
            node = node.clone
          end
          set_parent node, self
          node
        end
      else
        nodes.map! do |node|
          node = node.clone if node.attached?
          set_parent node, self
          node
        end
      end
      return nodes
    end
Prepare the given nodes for addition.  This means:
   -- clone any attached nodes as necessary
   -- set the nodes' parents to self.

 `oldnodes' are the nodes that will be replaced.  These aren't
 cloned the first time they appear in `nodes'.

 Return the list of nodes to add.