docs: @SuppressWarnings("unchecked")
      protected CaseFileInstance internalGetCaseFileInstance(String caseId, String deploymentId) {
          logger.debug("Retrieving case file from working memory for case " + caseId);
          Collection<CaseFileInstance> caseFiles = (Collection<CaseFileInstance>) processService.execute(deploymentId, CaseContext.get(caseId), commandsFactory.newGetObjects(new ClassObjectFilter(CaseFileInstance.class)));
          if (caseFiles.size() == 0) {
              throw new CaseNotFoundException("Case with id " + caseId + " was not found");
          } else if (caseFiles.size() == 1) {
              CaseFileInstance caseFile =  caseFiles.iterator().next();
              logger.debug("Single case file {} found in working memory", caseFile);
              
              // apply authorization
              Map<String, Object> filteredData = authorizationManager.filterByDataAuthorization(caseId, caseFile, caseFile.getData());
              ((CaseFileInstanceImpl)caseFile).setData(filteredData);
              
              for (Object variable : caseFile.getData().values()) {
                  if (variable instanceof LazyLoaded<?>) {
                      ((LazyLoaded<?>) variable).load();
                  }
              }
              
              return caseFile;
          } 
          logger.warn("Multiple case files found in working memory (most likely not using PER_CASE strategy), trying to filter out...");
          CaseFileInstance caseFile = caseFiles.stream()
                  .filter(cf -> cf.getCaseId().equals(caseId))
                  .findFirst()
                  .orElse(null);
          logger.warn("Case file {} after filtering {}", caseFile, (caseFile == null?"not found" : "found"));
          
          if (caseFile != null) {
              // apply authorization
              Map<String, Object> filteredData = authorizationManager.filterByDataAuthorization(caseId, caseFile, caseFile.getData());
              ((CaseFileInstanceImpl)caseFile).setData(filteredData);
              
  
              for (Object variable : caseFile.getData().values()) {
                  if (variable instanceof LazyLoaded<?>) {
                      ((LazyLoaded<?>) variable).load();
                  }
              }
          }
          
          
          return caseFile;
      }