code: function filterArray(pts, func) {
    if (!(pts[0] instanceof Array) || !(pts[0][0] instanceof Array)) {
      pts = func(pts);
      return pts;
    }
  
    var result = new Array(pts.length);
    for (var i = 0; i < pts.length; i++) {
      result[i] = filterArray(pts[i], func); //at array of arrays of points
    }
    return result;
  }
docs: Filter a geojson coordinates array structure.