function getContainerFrameForBGLayer(bg) {
  log(3, 'Getting container frame for background layer', bg)

  // Ignore layer if it is the BG, is an Artboard or has the prefix '-'
  var validLayers = filter(bg.parentGroup().layers(), function(layer) {
    if (layer == bg)
      return false
    if (layer.isMemberOfClass(MSArtboardGroup))
      return false
    if (layer.isMemberOfClass(MSSliceLayer))
      return false
    if (shouldLayerBeIgnored(layer))
      return false
    return true
  })

  // Get the rect for each layer, only if it exists
  var frames = []

  validLayers.forEach(function(layer) {
    var rect = rectForLayer(layer, true)
    if (rect) {
      frames.push(rect)
    }
  })

  return MSRect.rectWithUnionOfRects(frames)
}
Get the container frame for a BG layer
That is, the total frame of all siblings
taking into account transformations (e.g. rotation etc.)