code: def by_name(cls, session, name, **kwargs):
          
          classifier = cls.first(session, where=(cls.name == name,))
  
          if not kwargs.get('create_if_not_exists', False):
              return classifier
  
          if not classifier:
              splitted_names = [n.strip() for n in name.split(u'::')]
              classifiers = [u' :: '.join(splitted_names[:i + 1])
                             for i in range(len(splitted_names))]
              parent_id = None
              category = splitted_names[0]
  
              for c in classifiers:
                  classifier = cls.first(session, where=(cls.name == c,))
                  if not classifier:
                      classifier = Classifier(name=c, parent_id=parent_id,
                                              category=category)
                      session.add(classifier)
                  session.flush()
                  parent_id = classifier.id
  
          return classifier
docs: Get a classifier from a given name.
  
          :param session: SQLAlchemy session
          :type session: :class:`sqlalchemy.Session`
  
          :param name: name of the classifier
          :type name: `unicode
  
          :return: classifier instance
          :rtype: :class:`pyshop.models.Classifier`