code: def find_problems(cls):
          
          cls = get_result_class(cls)
          vendor = cls.get_database_vendor('write')
  
          evil_chars, bad_steplen, orphans = [], [], []
          wrong_depth, wrong_numchild = [], []
          for node in cls.objects.all():
              found_error = False
              for char in node.path:
                  if char not in cls.alphabet:
                      evil_chars.append(node.pk)
                      found_error = True
                      break
              if found_error:
                  continue
              if len(node.path) % cls.steplen:
                  bad_steplen.append(node.pk)
                  continue
              try:
                  node.get_parent(True)
              except cls.DoesNotExist:
                  orphans.append(node.pk)
                  continue
  
              if node.depth != int(len(node.path) / cls.steplen):
                  wrong_depth.append(node.pk)
                  continue
  
              real_numchild = cls.objects.filter(
                  path__range=cls._get_children_path_interval(node.path)
              ).extra(
                  where=[(sql_length("path", vendor=vendor) + '/%d=%d') % (cls.steplen, node.depth + 1)]
              ).count()
              if real_numchild != node.numchild:
                  wrong_numchild.append(node.pk)
                  continue
  
          return evil_chars, bad_steplen, orphans, wrong_depth, wrong_numchild
docs: Checks for problems in the tree structure, problems can occur when:
  
             1. your code breaks and you get incomplete transactions (always
                use transactions!)
             2. changing the ``steplen`` value in a model (you must
                :meth:`dump_bulk` first, change ``steplen`` and then
                :meth:`load_bulk`
  
          :returns: A tuple of five lists:
  
                    1. a list of ids of nodes with characters not found in the
                       ``alphabet``
                    2. a list of ids of nodes when a wrong ``path`` length
                       according to ``steplen``
                    3. a list of ids of orphaned nodes
                    4. a list of ids of nodes with the wrong depth value for
                       their path
                    5. a list of ids nodes that report a wrong number of children