code: public static void connectElements( List<IHillSlope> elements ) {
          Collections.sort(elements, elements.get(0));
  
          for( int i = 0; i < elements.size(); i++ ) {
              IHillSlope elem = elements.get(i);
              for( int j = i + 1; j < elements.size(); j++ ) {
                  IHillSlope tmp = elements.get(j);
                  elem.addConnectedDownstreamElementWithCheck(tmp);
              }
          }
      }
docs: Connect the various elements in a chain of tributary basins and nets
  
  @param elements