private double walkThrough(TVC[] connections, Firewall[] firewalls) throws Exception {

    int num = connections.length;
    
    double d1 = Double.MAX_VALUE;
    double d2 = Double.MAX_VALUE;
    
    for (TVC c : connections) {
      
      // Left branch
      firewalls[c.getFirewallId1()].manageConnection(c);  
      
      TVC[] subset = copySetWithout(c, connections);
      if (num > 1) {
        d1 = walkThrough(subset, firewalls);
      } else {
        d1 = environment.dispersion();
        stepsCount ++;
      }
      
      //right branch
      firewalls[c.getFirewallId2()].manageConnection(c);
      if (num > 1) {
        d2 = walkThrough(subset, firewalls);
      } else {
        d2 = environment.dispersion();
        stepsCount ++;
      }
    }
    
    return Math.min(d1, d2);
  }