Dropdown rework

My current dropdown code always has a sub-dropdown.
This is great when there is more than one group in a dropdown.

This is... not so greatAWFUL when there is only a single group in the dropdown.

GOAL

I want to have code output this:

<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Bootstrap<b class="caret">
    </b>
  </a>
  <ul class="dropdown-menu">
    <li>
      <a class="wikilink" href="/Bootstrap/Bootstrap">Bootstrap</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/EditForm">EditForm</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/EditQuickReference">EditQuickReference</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/LocalTemplates">LocalTemplates</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/Markup">Markup</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/Sandbox">Sandbox</a>
    </li>
    <li>
      <a class="wikilink" href="/Bootstrap/StyleOptions">StyleOptions</a>
    </li>
  </ul>
</li>

Done (not implemented here)

Nor has this been committed to github.

No markup changes are required.
Existing markup that generates dropdown menus will produce a single dropdown (no sub-menu) when one group is present:

Existing markup that generates dropdown menus will produce a dropdown with sub-menus when more than one group is present:

Done (implemented here)