code: private void findIdThatDrainsIntoIndex( int index, Coordinate cord ) {
          int t = 0;
          double toll = 0.1;
          for( int i = 0; i < networkPipes.length; i++ ) {
              // if it is this pipe then go haead.
              if (index == i) {
                  continue;
              }
              // there isn-t other pipe that can drain in this.
              else if (t == pMaxJunction) {
                  break;
              }
              // the id is already set.
              else if (networkPipes[i].getIdPipeWhereDrain() != null) {
                  continue;
              }
              // extract the coordinate of the point of the linee of the new pipe.
              Coordinate[] coords = networkPipes[i].point;
              // if one of the coordinates are near of coord then the 2 pipe are
              // linked.
              int lastIndex = coords.length - 1;
              if (cord.distance(coords[0]) < toll) {
                  networkPipes[i].setIdPipeWhereDrain(networkPipes[index].getId());
                  networkPipes[i].setIndexPipeWhereDrain(index);
                  findIdThatDrainsIntoIndex(i, coords[lastIndex]);
                  t++;
              } else if (cord.distance(coords[lastIndex]) < toll) {
                  networkPipes[i].setIdPipeWhereDrain(networkPipes[index].getId());
                  networkPipes[i].setIndexPipeWhereDrain(index);
                  findIdThatDrainsIntoIndex(i, coords[0]);
                  t++;
              }
  
          }
  
      }
docs: Find the pipes that are draining in this pipe (defined by the index parameter).
  
  @param index
  the ID of this pipe.
  @param cord
  the Coordinate of the link where drain.