private List<Debugger.Variable> collectVariables() {
    final Set<Debugger.Variable> variables = new HashSet<>();

    ElemTemplateElement p = myCurrentElement;
    while (p != null) {
      ElemTemplateElement s = p;
      while ((s = s.getPreviousSiblingElem()) != null) {
        if (s instanceof ElemVariable) {
          final ElemVariable variable = (ElemVariable)s;
          if (variable.getIsTopLevel()) {
            continue;
          }

          addVariable(variable, false, variables);
        }
      }
      p = p.getParentElem();
    }

    @SuppressWarnings({"unchecked", "UseOfObsoleteCollectionType"})
    final Vector<ElemVariable> globals = myTransformer.getStylesheet().getVariablesAndParamsComposed();
    for (ElemVariable variable : globals) {
      addVariable(variable, true, variables);
    }

    final ArrayList<Debugger.Variable> result = new ArrayList<>(variables);
    result.sort(VariableComparator.INSTANCE);
    return result;
  }
private List<Debugger.Variable> collectVariables()