private Pair<Integer, Boolean> findPreferredSectionLine(@NotNull String sectionTitle) {
    final String normalized = SectionBasedDocString.getNormalizedSectionTitle(sectionTitle);
    final int index = CANONICAL_SECTION_ORDER.indexOf(normalized);
    if (index < 0) {
      return Pair.create(findLastNonEmptyLine(), true);
    }
    final Map<String, Section> namedSections = new HashMap<>();
    for (Section section : myOriginalDocString.getSections()) {
      final String normalizedTitle = section.getNormalizedTitle();
      // leave only first occurrences
      if (!namedSections.containsKey(normalizedTitle)) {
        namedSections.put(normalizedTitle, section);
      }
    }
    for (int i = index - 1; i >= 0; i--) {
      final Section previous = namedSections.get(CANONICAL_SECTION_ORDER.get(i));
      if (previous != null) {
        return Pair.create(getSectionEndLine(previous), true);
      }
    }
    for (int i = index + 1; i < CANONICAL_SECTION_ORDER.size(); i++) {
      final Section next = namedSections.get(CANONICAL_SECTION_ORDER.get(i));
      if (next != null) {
        return Pair.create(getSectionStartLine(next), false);
      }
    }
    return Pair.create(findLastNonEmptyLine(), true);
  }
private Pair<Integer, Boolean> findPreferredSectionLine(@NotNull String sectionTitle)