@SuppressWarnings("unchecked")
public List<KeyValue<String, HeadElement>> getHeadElements()
{
if (headElements == null && fragment != null && fragment.getPortletContent() != null)
{
PortletContent portletContent = fragment.getPortletContent();
if (portletContent.isComplete() || !Fragment.PORTLET.equals(fragment.getType()))
{
// org.apache.commons.collections.list.TreeList is well-optimized for
// fast insertions at any index in the list.
// Refer to description in the javadoc for details.
headElements = new TreeList();