public void processVariable(final String name, XmlTag tag) {
      ResolveUtil.treeWalkUp(new ElementProcessor<>(tag) {
        boolean myContinue = true;

        @Override
        protected void processTemplate(XmlTag tag) {
          myContinue = false;
        }

        @Override
        protected void processVarOrParam(XmlTag tag) {
          if (tag != myRoot && name.equals(tag.getAttributeValue("name"))) {
            assert myContinue;
            if (XsltSupport.getXsltLanguageLevel(tag.getContainingFile()) == XsltChecker.LanguageLevel.V2) {
              myShadows.put(myRoot, tag);
            }
            else {
              myDuplications.put(myRoot, tag);
            }
          }
        }

        @Override
        protected boolean shouldContinue() {
          return myContinue;
        }

        @Override
        protected boolean followImport() {
          return false;
        }
      }, tag);

      if (insideTemplate()) {
        XmlTag var = myTopLevelVariables.get(name);

        if (var != null) {
          myShadows.put(tag, var);
        }
      }
      myVariableDeclarations.put(name, tag);
    }
public void processVariable(final String name, XmlTag tag)