code: function() {
          var candidates = this.layers || this.map.layers;
          var layers = [];
          var layer;
          for (var i=candidates.length-1; i>=0; --i) {
              layer = candidates[i];
              if (layer instanceof OpenLayers.Layer.WMTS &&
                  layer.requestEncoding === this.requestEncoding &&
                  (!this.queryVisible || layer.getVisibility())) {
                  layers.push(layer);
                  if (!this.drillDown || this.hover) {
                      break;
                  }
              }
          }
          return layers;
      }
docs: Method: findLayers
  Internal method to get the layers, independent of whether we are
  inspecting the map or using a client-provided array