code: def levels(self, with_mem=True):
          
          p = self.first_level
          while p is not None:
              yield p
              # FIXME bad hack to include victim caches, need a more general solution, probably
              # involving recursive tree walking
              if p.victims_to is not None and p.victims_to != p.load_from:
                  yield p.victims_to
              if p.store_to is not None and p.store_to != p.load_from and p.store_to != p.victims_to:
                  yield p.store_to
              p = p.load_from
  
          if with_mem:
              yield self.main_memory
docs: Return cache levels, optionally including main memory.