def filterTestsbyDifficulty(self,testsOfType,chosenDif,res):
    success=False
    d=dict()
    intDif=int(chosenDif)
    if(intDif==0):
      return success,d
    else:
      for i in range(len(testsOfType.tests)):
        if(testsOfType.difficulty[i]==chosenDif):
          tlist=[testsOfType.file_paths[i],testsOfType.difficulty[i],testsOfType.subtype[i]]
          d[testsOfType.tests[i]]=[tlist]

      if(not len(d)>0):
        res.trace.append("downscaling difficulty by 1 as no test exists for diff = " +chosenDif);
        chosenDif=str(int(chosenDif)-1)
        success,d=self.filterTestsbyDifficulty(testsOfType,chosenDif,res)
      else:
        success=True
      return success,d

  ## @brief Gets the users ontology alias and if it doesnt exist it creates it  
  # @param username [string] The user's username
  # @param res [rapp_platform_ros_communications::testSelectorSrvResponse::Response&] The output arguments of the service as defined in the testSelectorSrv
  #
  # @return res [rapp_platform_ros_communications::testSelectorSrvResponse::Response&] The output arguments of the service as defined in the testSelectorSrv
  # @return returnWithError [bool] True if a non recoverable error occured, and the service must immediately return with an error report
  # @return ontologyAlias [string] The user's ontology alias
dataset/ETHPy150Open rapp-project/rapp-platform/rapp_cognitive_exercise/src/test_selector.py/TestSelector.filterTestsbyDifficulty/original