code: def _cells(nb):
      
      if nb.nbformat < 4:
          for ws in nb.worksheets:
              for cell in ws.cells:
                  yield cell
      else:
          for cell in nb.cells:
              yield cell
docs: Yield all cells in an nbformat-insensitive manner