docs: def build_classes(self, hide_base_schemas=True, hide_implicit_types=True):
          """
          2015-06-04: removed sparql 1.1 queries
          2015-05-25: optimized via sparql queries in order to remove BNodes
          2015-05-09: new attempt
  
          Note: sparqlHelper.getAllClasses() returns a list of tuples,
          (class, classRDFtype)
          so in some cases there are duplicates if a class is both RDFS.CLass and OWL.Class
          In this case we keep only OWL.Class as it is more informative.
          """
  
          self.all_classes = []  # @todo: keep adding?
  
          qres = self.sparqlHelper.getAllClasses(hide_base_schemas,
                                                 hide_implicit_types)
          # print("rdflib query done")
  
          for class_tuple in qres:
  
              _uri = class_tuple[0]
              try:
                  _type = class_tuple[1]
              except:
                  _type = ""
  
              test_existing_cl = self.get_class(uri=_uri)
              if not test_existing_cl:
                  # create it
                  ontoclass = OntoClass(_uri, _type, self.namespaces)
                  self.all_classes += [ontoclass]
              else:
                  # if OWL.Class over RDFS.Class - update it
                  if _type == rdflib.OWL.Class:
                      test_existing_cl.rdftype = rdflib.OWL.Class
  
          # print("classes created")
  
          # add more data
          for aClass in self.all_classes:
              # print("enriching class", aClass)
              aClass.triples = self.sparqlHelper.entityTriples(aClass.uri)
              aClass._buildGraph()  # force construction of mini graph
  
              aClass.sparqlHelper = self.sparqlHelper
  
              # attach to an ontology
              for uri in aClass.getValuesForProperty(rdflib.RDFS.isDefinedBy):
                  onto = self.get_ontology(uri=str(uri))
                  if onto:
                      onto.all_classes += [aClass]
                      aClass.ontology = onto
  
              # add direct Supers
              directSupers = self.sparqlHelper.getClassDirectSupers(aClass.uri)
  
              for x in directSupers:
                  superclass = self.get_class(uri=x[0])
                  # note: extra condition to avoid recursive structures
                  if superclass and superclass.uri != aClass.uri:
                      aClass._parents.append(superclass)
  
                      # add inverse relationships (= direct subs for superclass)
                      if aClass not in superclass.children():
                          superclass._children.append(aClass)
  
          # sort alphabetically
          self.all_classes = sorted(self.all_classes, key=lambda x: x.qname)
  
          # compute top layer
          # print("calc toplayer")
          exit = []
          for c in self.all_classes:
              if not c.parents():
                  exit += [c]
          self.toplayer_classes = exit