code: def nodes_map(self):
          
          dct = dict()
          for node in self.nodes.values():
              cls = next(base for base in getmro(node.__class__) if "__tablename__" in base.__dict__)
              key = getattr(cls, "__alias__", underscore(cls.__name__))
              dct.setdefault(key, []).append(node)
          return dct
docs: Build a mapping from node type to a list of nodes.
  
          A typed mapping helps avoid polymorphism at non-persistent layers.