private void removeShortStubEdges() {
    PriorityQueue<Edge> toCheck = new PriorityQueue<>(Comparator.comparingDouble(Edge::length));
    for (var node : output) {
      for (var edge : node.getEdges()) {
        if (isShortStubEdge(edge)) {
          toCheck.offer(edge);
        }
      }
    }
    while (!toCheck.isEmpty()) {
      var edge = toCheck.poll();
      if (edge.removed) {
        continue;
      }
      if (isShortStubEdge(edge)) {
        edge.remove();
      }
      if (degreeTwoMerge(edge.from) instanceof Edge merged) {
        toCheck.offer(merged);
      }
      if (edge.from.getEdges().size() == 1) {
        var other = edge.from.getEdges().getFirst();
        if (isShortStubEdge(other)) {
          toCheck.offer(other);
        }
      }
      if (edge.from != edge.to) {
        if (degreeTwoMerge(edge.to) instanceof Edge merged) {
          toCheck.offer(merged);
        }
        if (edge.to.getEdges().size() == 1) {
          var other = edge.to.getEdges().getFirst();
          if (isShortStubEdge(other)) {
            toCheck.offer(other);
          }
        }
      }
    }
  }
Adds a geometry to the merger. Only linestrings from the input geometry are considered.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java