code: @SuppressWarnings("unchecked")
      public static List<LineString> mergeLinestrings( List<LineString> multiLines ) {
          LineMerger lineMerger = new LineMerger();
          for( int i = 0; i < multiLines.size(); i++ ) {
              Geometry line = multiLines.get(i);
              lineMerger.add(line);
          }
          Collection<Geometry> merged = lineMerger.getMergedLineStrings();
          List<LineString> mergedList = new ArrayList<>();
          for( Geometry geom : merged ) {
              mergedList.add((LineString) geom);
          }
          return mergedList;
      }
docs: Tries to merge multilines when they are snapped properly.
  
  @param multiLines the lines to merge.
  @return the list of lines, ideally containing a single line,merged.