private void fillVariableMap(MatchResult r) {
    final String name = r.getName();
    if (name != null) {
      variableMap.putIfAbsent(name, r);
      sourceNameToSearchPatternNameMap.put(r.getMatchImage(), name);
    }

    if (!r.isScopeMatch() || !r.isMultipleMatch()) {
      for (final MatchResult matchResult : r.getChildren()) {
        fillVariableMap(matchResult);
      }
    } else if (r.hasChildren()) {
      fillVariableMap(r.getChildren().get(0));
    }
  }
private void fillVariableMap(MatchResult r)