function findLayersInLayer(
  name,
  exactMatch,
  type,
  rootLayer,
  subLayersOnly,
  layersToExclude
) {
  // create predicate format
  let formatRules = ['(name != NULL)']
  let args = []

  // name
  if (name) {
    if (exactMatch) {
      formatRules.push('(name == %@)')
    } else {
      formatRules.push('(name like %@)')
    }
    args.push(name)
  }

  // type
  if (type) {
    if (type === SHAPE) {
      formatRules.push(
        '(className == "MSRectangleShape" OR className == "MSTriangleShape" OR className == "MSOvalShape" OR className == "MSStarShape" OR className == "MSPolygonShape" OR className == "MSShapeGroup")'
      )
    } else {
      formatRules.push('(className == %@)')
    }
    args.push(type)
  } else {
    formatRules.push(
      '(className == "MSLayerGroup" OR className == "MSShapeGroup" OR className == "MSArtboardGroup" OR className == "MSTextLayer" OR className == "MSRectangleShape" OR className == "MSTriangleShape" OR className == "MSOvalShape" OR className == "MSStarShape" OR className == "MSPolygonShape")'
    )
  }

  // layers to exclude
  if (layersToExclude) {
    formatRules.push('NOT (SELF IN %@)')
    args.push(layersToExclude)
  }

  // prepare format string
  let formatString = formatRules.join(' AND ')

  // create predicate
  let predicate = NSPredicate.predicateWithFormat_argumentArray(formatString, args)

  // get layers to filter
  let layers
  if (subLayersOnly) {
    layers = rootLayer.layers()
  } else {
    layers = rootLayer.children()
  }

  // perform query
  let queryResult = layers.filteredArrayUsingPredicate(predicate)

  // return result as js array
  return Utils.convertToJSArray(queryResult)
}
Finds layers with specified name in the root layer. The name can be set to '*'
and exactMatch to false, in which case all layers are returned.

@param {String} name
@param {Boolean} exactMatch
@param {String} type
@param {MSLayer} rootLayer
@param {Boolean} subLayersOnly
@param {Array} layersToExclude
@returns {Array}