code: def GetLayerFromFeatureService(self, fs, layerName="", returnURLOnly=False):
          
          layers = None
          table = None
          layer = None
          sublayer = None
          try:
              layers = fs.layers
              if (layers is None or len(layers) == 0) and fs.url is not None:
                  fs = arcrest.ags.FeatureService(
                                      url=fs.url)
                  layers = fs.layers
              if layers is not None:
                  for layer in layers:
                      if layer.name == layerName:
                          if returnURLOnly:
                              return fs.url + '/' + str(layer.id)
                          else:
                              return layer
  
                      elif not layer.subLayers is None:
                          for sublayer in layer.subLayers:
                              if sublayer == layerName:
                                  return sublayer
              if fs.tables is not None:
                  for table in fs.tables:
                      if table.name == layerName:
                          if returnURLOnly:
                              return fs.url + '/' + str(layer.id)
                          else:
                              return table
              return None
  
          except:
              line, filename, synerror = trace()
              raise common.ArcRestHelperError({
                          "function": "GetLayerFromFeatureService",
                          "line": line,
                          "filename":  filename,
                          "synerror": synerror,
                                          }
                                          )
          finally:
              layers = None
              table = None
              layer = None
              sublayer = None
              del layers
              del table
              del layer
              del sublayer
              gc.collect()
docs: Obtains a layer from a feature service by feature service reference.
  
          Args:
              fs (FeatureService): The feature service from which to obtain the layer.
              layerName (str): The name of the layer. Defaults to ``""``.
              returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
          Returns:
              When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
  
              When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.