@NotNull
  @Override
  public Collection<StructureViewTreeElement> getChildrenBase() {
    Collection<StructureViewTreeElement> result = new LinkedList<>();

    final NavigatablePsiElement element = getElement();
    if (element == null) {
      return result;
    }

    final PsiFile file = element.getContainingFile();
    final TextRange range = element.equals(file) ? TextRange.EMPTY_RANGE : element.getTextRange();
    Pair<Character, Character> elementAdornments = element instanceof RestTitle ? ((RestTitle)element).getAdornments() : Pair.empty();

    Pair<Character, Character> adornmentsToUse = null;
    final Collection<RestTitle> titles = PsiTreeUtil.findChildrenOfType(file, RestTitle.class);
    final HashSet<Pair<Character, Character>> usedAdornments = new HashSet<>();
    boolean skipElements = false;

    for (RestTitle child : titles) {
      final Pair<Character, Character> childAdornments = child.getAdornments();

      if (child.getTextRange().getStartOffset() >= range.getEndOffset()) {
        final Character overline = childAdornments.getFirst();
        final Character underline = childAdornments.getSecond();
        if (adornmentsToUse == null) {
          adornmentsToUse = childAdornments;
        }
        if (usedAdornments.contains(childAdornments) || underline == null) {
          break;
        }
        if (underline.equals(adornmentsToUse.getSecond()) && ((adornmentsToUse.getFirst() == null && overline == null) ||
                                                              (overline != null && overline.equals(adornmentsToUse.getFirst())))) {
          result.add(new RestStructureViewElement(child));
        }
      }
      else {
        if (element.equals(child)) {
          skipElements = false;
        }
        else if (childAdornments.equals(elementAdornments)) {
          skipElements = true;
        }

        if (!skipElements) {
          usedAdornments.add(child.getAdornments());
        }
      }
    }
    return result;
  }
@NotNull
  @Override
  public Collection<StructureViewTreeElement> getChildrenBase()