code: def _flatten_list(x):
      
      result = []
      # Remove None
      x = list(filter(None.__ne__, x))
      for el in x:
          x_is_iter = isinstance(x, collections.Iterable)
          if x_is_iter and not isinstance(el, (str, tuple)):
              result.extend(_flatten_list(el))
          else:
              result.append(el)
      return result
docs: Flatten an arbitrarily nested list into a new list.
  
      This can be useful to select pandas DataFrame columns.
  
      From https://stackoverflow.com/a/16176969/10581531
  
      Examples
      --------
      >>> from pingouin.utils import _flatten_list
      >>> x = ['X1', ['M1', 'M2'], 'Y1', ['Y2']]
      >>> _flatten_list(x)
      ['X1', 'M1', 'M2', 'Y1', 'Y2']
  
      >>> x = ['Xaa', 'Xbb', 'Xcc']
      >>> _flatten_list(x)
      ['Xaa', 'Xbb', 'Xcc']