/**
   * Gets the header part of the Panel/Border. Returns null if it doesn't have a header tag.
   *
   * @param container
   * @param id
   * @param markup
   * @return the header part for this panel/border or null if it doesn't have a wicket:head tag.
   */
  private HeaderPartContainer getHeaderPart(
      final WebMarkupContainer container, final String id, final IMarkupFragment markup) {
    // Create a HtmlHeaderContainer for the header tag found
    final MarkupElement element = markup.get(0);
    if (element instanceof WicketTag) {
      final WicketTag wTag = (WicketTag) element;
      if ((wTag.isHeadTag() == true) && (wTag.getNamespace() != null)) {
        // Create the header container and associate the markup with it
        return new HeaderPartContainer(id, container, markup);
      }
    }

    throw new WicketRuntimeException(
        "Programming error: expected a WicketTag: " + markup.toString());
  }