ureech,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div id="6" class="comment" data-parent="0" data-level="1">6...</div>
<div id="7" class="comment" data-parent="6" data-level="2">7...</div>
<div id="8" class="comment" data-parent="6" data-level="2">8...</div>
<div id="9" class="comment" data-parent="6" data-level="2">9...</div>
<div id="10" class="comment" data-parent="0" data-level="1">10...</div>
<div id="11" class="comment" data-parent="10" data-level="2">11...</div>
<div id="12" class="comment" data-parent="10" data-level="2">12...</div>
<div id="13" class="comment" data-parent="10" data-level="2">13...</div>
<script>
var elem = document.querySelectorAll(".comment[data-level='2']");
let tag_a = document.createElement('a');
tag_a.textContent = '--------Смотреть все---------';
let obj = {};
elem.forEach(el => {
let {
parent
} = el.dataset;
obj[parent] ??= 0;
if (obj[parent] == 1) el.before(tag_a.cloneNode(true));
obj[parent]++;
})
</script>
</body>
</html>