Creating a navigation with Category headings

I have a list of items (which are folders in a $page) and I want to create a navigation that does something like this:

Category Heading

  • Item
  • Item
    Category Heading
  • Item
  • Item

I’m trying to utilize the pluck() function but the documentation for it seems lacking and I can’t figure out how to only display the Category Heading once. This is what I have so far:

<div class="container">
	<div class="row">
		<div class="col-md-10 col-md-offset-1">
			<?php echo $page->text()->kirbytext() ?>
				<ul>
					<?php foreach($page->children()->pluck('category', 'true') as $title): ?>
						<li><?php echo $title->unique()->html() ?></li>
					<?php endforeach ?>
				</ul>
			<hr>
			<?php foreach($page->children() as $finalist): ?>

			<div class="row" id="<?php echo $finalist->link()->html() ?>" >
				<div class="col-md-3">
					<span class="all-caps text-info small">Company</span>
					<br>
					<img class="" style="max-height:135px; background-color:#E2E7EB; padding:10px;" src="<?php echo $finalist->images()->nth(1)->url() ?>" alt="<?php echo $finalist->title()->html() ?> logo">
				</div>
				<div class="col-md-5">
					<span class="all-caps text-info small">Project</span>
					<p class="lead "><?php echo $finalist->headline()->html() ?></p>
					
				</div>
				<div class="col-md-4">
					<span class="all-caps text-info small">Category</span>
					<p class="lead"><?php echo $finalist->category()->html() ?></p>
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
					<hr class="double">
					<img src="<?php echo $finalist->images()->first()->url() ?>" alt="<?php echo $finalist->headline()->html() ?>">
					<p><?php echo $finalist->text()->kirbytext() ?></p>
					<hr>
				</div>
			</div>
		<?php endforeach ?>
		</div>
	</div>
</div>
<?php foreach($page->children()->pluck('category', null, true) as $title): ?>
  <li><?php echo $title->html() ?></li>
<?php endforeach ?>

But if you want your articles to be listed after each header, you would have to filter all articles accordingly within the foreach loop.