code: def __flushLevel(self, level):
          
          objectsCount = len(self.objectsStack)
  
          while objectsCount > level:
              lastIndex = objectsCount - 1
              if lastIndex == 0:
                  # We have exactly one element in the stack
                  if self.objectsStack[0].__class__.__name__ == "Class":
                      self.classes.append(self.objectsStack[0])
                  else:
                      self.functions.append(self.objectsStack[0])
                  self.objectsStack = []
                  break
  
              # Append to the previous level
              if self.objectsStack[lastIndex].__class__.__name__ == "Class":
                  self.objectsStack[lastIndex - 1].classes. \
                      append(self.objectsStack[lastIndex])
              else:
                  self.objectsStack[lastIndex - 1].functions. \
                      append(self.objectsStack[lastIndex])
  
              del self.objectsStack[lastIndex]
              objectsCount -= 1
docs: Merge the found objects to the required level