docs: def get_collections(self, unit, names=None, merge=False,
                          sampling_rate=None, **entities):
          ''' Retrieve variable data for a specified level in the Dataset.
  
          Args:
              unit (str): The unit of analysis to return variables for. Must be
                  one of 'run', 'session', 'subject', or 'dataset'.
              names (list): Optional list of variables names to return. If
                  None, all available variables are returned.
              merge (bool): If True, variables are merged across all observations
                  of the current unit. E.g., if unit='subject' and return_type=
                  'collection', variablesfrom all subjects will be merged into a
                  single collection. If False, each observation is handled
                  separately, and the result is returned as a list.
              sampling_rate (int, str): If unit='run', the sampling rate to
                  pass onto the returned BIDSRunVariableCollection.
              entities: Optional constraints used to limit what gets returned.
  
          Returns:
  
          '''
  
          nodes = self.get_nodes(unit, entities)
          var_sets = []
  
          for n in nodes:
              var_set = list(n.variables.values())
              var_set = [v for v in var_set if v.matches_entities(entities)]
              if names is not None:
                  var_set = [v for v in var_set if v.name in names]
              # Additional filtering on Variables past run level, because their
              # contents are extracted from TSV files containing rows from
              # multiple observations
              if unit != 'run':
                  var_set = [v.filter(entities) for v in var_set]
              var_sets.append(var_set)
  
          if merge:
              var_sets = [list(chain(*var_sets))]
  
          results = []
          for vs in var_sets:
              if not vs:
                  continue
              if unit == 'run':
                  vs = clc.BIDSRunVariableCollection(vs, sampling_rate)
              else:
                  vs = clc.BIDSVariableCollection(vs)
              results.append(vs)
  
          if merge:
              return results[0] if results else None
  
          return results