code: private static int countCoordRepeatReverse(Coordinate[] coords) {
          int repeatCoords = 0;
  
          final Coordinate firstCoord = coords[0];
          Coordinate nextCoord;
  
          for(int i = coords.length - 1; i > 0; --i) {
              nextCoord = coords[i];
              if(equalAsInts2d(firstCoord, nextCoord)) {
                  ++repeatCoords;
              } else {
                  break;
              }
          }
  
          return repeatCoords;
      }
docs: <p>Count number of coordinates starting from the end of the coordinate array backwards
  that match the first coordinate value.</p>
  
  <p>Useful for ensuring self-closing line strings do not repeat the first coordinate.</p>
  
  @param coords coordinates to check for duplicate points
  @return number of duplicate points at the rear of the list