def direct_connect!
      models = @model.each_child.to_a
      children_list = []
      new_internal_couplings = Hash.new { |h, k| h[k] = [] }

      i = 0
      while i < models.size
        model = models[i]
        if model.coupled?
          # get internal couplings between atomics that we can reuse as-is in the root model
          model.each_internal_coupling do |src, dst|
            if src.host.atomic? && dst.host.atomic?
              new_internal_couplings[src] << dst
            end
          end
          model.each_child { |c| models << c }
        else
          children_list << model
        end
        i += 1
      end

      cm = @model
      cm.each_child.each { |c| cm.remove_child(c) }
      children_list.each { |c| cm << c }

      find_direct_couplings(cm) do |src, dst|
        new_internal_couplings[src] << dst
      end

      internal_couplings = cm.instance_variable_get(:@internal_couplings).clear
      internal_couplings.merge!(new_internal_couplings)
    end
def direct_connect!
      models = @model.each_child.to_a
      children_list = []
      new_internal_couplings = Hash.new { |h, k| h[k] = [] }

      i = 0
      while i < models.size
        model = models[i]
        if model.coupled?
          # get internal couplings between atomics that we can reuse as-is in the root model
          model.each_internal_coupling do |src, dst|
            if src.host.atomic? && dst.host.atomic?
              new_internal_couplings[src] << dst
            end
          end
          model.each_child { |c| models << c }
        else
          children_list << model
        end
        i += 1
      end

      cm = @model
      cm.each_child.each { |c| cm.remove_child(c) }
      children_list.each { |c| cm << c }

      find_direct_couplings(cm) do |src, dst|
        new_internal_couplings[src] << dst
      end

      internal_couplings = cm.instance_variable_get(:@internal_couplings).clear
      internal_couplings.merge!(new_internal_couplings)
    end
TODO Don't destruct the old hierarchy