private static void collectAttributes(@NotNull Set<? super String> referenced,
                                        @NotNull Set<? super String> defined,
                                        @NotNull Node apacheNode,
                                        @NotNull Set<String> propertiesNames,
                                        final boolean includeDummies,
                                        @NotNull Set<? super String> visitedIncludes,
                                        @NotNull Project project) throws ParseException {
    int childCount = apacheNode.jjtGetNumChildren();
    for (int i = 0; i < childCount; i++) {
      Node apacheChild = apacheNode.jjtGetChild(i);
      collectAttributes(referenced, defined, apacheChild, propertiesNames, includeDummies, visitedIncludes, project);
      if (apacheChild instanceof ASTReference) {
        String s = apacheChild.literal();
        s = referenceToAttribute(s, includeDummies);
        if (s != null && s.length() > 0 && !propertiesNames.contains(s)) {
          referenced.add(s);
        }
      }
      else if (apacheChild instanceof ASTSetDirective) {
        Node lhs = apacheChild.jjtGetChild(0);
        String attr = referenceToAttribute(lhs.literal(), false);
        if (attr != null) {
          defined.add(attr);
        }
      }
      else if (apacheChild instanceof ASTDirective && "parse".equals(((ASTDirective)apacheChild).getDirectiveName()) && apacheChild.jjtGetNumChildren() == 1) {
        Node literal = apacheChild.jjtGetChild(0);
        if (literal instanceof ASTStringLiteral && literal.jjtGetNumChildren() == 0) {
          Token firstToken = literal.getFirstToken();
          if (firstToken != null) {
            String s = StringUtil.unquoteString(firstToken.toString());
            FileTemplateManager templateManager = FileTemplateManager.getInstance(project);
            FileTemplate includedTemplate = templateManager.getTemplate(s);
            if (includedTemplate == null) {
              includedTemplate = templateManager.getPattern(s);
            }
            if (includedTemplate != null && visitedIncludes.add(s)) {
              SimpleNode template = VelocityWrapper.parse(new StringReader(includedTemplate.getText()));
              collectAttributes(referenced, defined, template, propertiesNames, includeDummies, visitedIncludes, project);
            }
          }
        }
      }
    }
  }
private static void collectAttributes(@NotNull Set<? super String> referenced,
                                        @NotNull Set<? super String> defined,
                                        @NotNull Node apacheNode,
                                        @NotNull Set<String> propertiesNames,
                                        final boolean includeDummies,
                                        @NotNull Set<? super String> visitedIncludes,
                                        @NotNull Project project)