code: private Set<String> getPagePathsForTemplate(String[] templates, String rootPath, SlingHttpServletRequest request) {
      Set<String> pagePaths = new HashSet<>();
  
      if (templates != null && templates.length > 0) {
        try {
          NodeIterator nodes = searchNodesByTemplate(templates, rootPath, request);
          while (nodes.hasNext()) {
            Node node = nodes.nextNode();
            String path = StringUtils.removeEnd(node.getPath(), "/jcr:content");
            pagePaths.add(path);
          }
        }
        catch (RepositoryException ex) {
          log.warn("Seaching nodes by template failed.", ex);
        }
      }
  
      return pagePaths;
    }
docs: Get paths for pages that use the given template
  
  @param templates
  @param rootPath
  @return a set of nodes that should be displayed in the tree