code: public List<CmsJspNavElement> getNavigationTreeForFolder(String folder, int startlevel, int endlevel) {
  
          folder = CmsResource.getFolderPath(folder);
          // Make sure start and end level make sense
          if (endlevel < startlevel) {
              return Collections.<CmsJspNavElement> emptyList();
          }
          int currentlevel = CmsResource.getPathLevel(folder);
          if (currentlevel < endlevel) {
              endlevel = currentlevel;
          }
          if (startlevel == endlevel) {
              return getNavigationForFolder(CmsResource.getPathPart(folder, startlevel), startlevel);
          }
  
          List<CmsJspNavElement> result = new ArrayList<CmsJspNavElement>();
          float parentcount = 0;
  
          for (int i = startlevel; i <= endlevel; i++) {
              String currentfolder = CmsResource.getPathPart(folder, i);
              List<CmsJspNavElement> entries = getNavigationForFolder(currentfolder);
              // Check for parent folder
              if (parentcount > 0) {
                  for (CmsJspNavElement e : entries) {
                      e.setNavPosition(e.getNavPosition() + parentcount);
                  }
              }
              // Add new entries to result
              result.addAll(entries);
              Collections.sort(result);
              // Finally spread the values of the navigation items so that there is enough room for further items
              float pos = 0;
              int count = 0;
              String nextfolder = CmsResource.getPathPart(folder, i + 1);
              parentcount = 0;
              for (CmsJspNavElement e : result) {
                  pos = 10000 * (++count);
                  e.setNavPosition(pos);
                  if (e.getResourceName().startsWith(nextfolder)) {
                      parentcount = pos;
                  }
              }
              if (parentcount == 0) {
                  parentcount = pos;
              }
          }
          return result;
      }
docs: Builds a tree navigation for the folders between the provided start and end level.<p>
  
  @param folder the selected folder
  @param startlevel the start level
  @param endlevel the end level
  
  @return a sorted list of navigation elements with the navigation tree level property set