@Test
public void rootNoDestinationAndSorted() {

    PDPage page1 = new PDPage();
    PDPage page2 = new PDPage();
    PDDocument document = new PDDocument();
    document.addPage(page1);
    document.addPage(page2);
    PDDocumentOutline outlines = new PDDocumentOutline();
    PDOutlineItem root = new PDOutlineItem();
    root.setTitle("title");
    PDOutlineItem child = new PDOutlineItem();
    child.setTitle("child");
    child.setDestination(page2);
    PDOutlineItem child2 = new PDOutlineItem();
    child2.setTitle("child2");
    child2.setDestination(page1);
    root.addFirst(child);
    root.addLast(child2);
    outlines.addFirst(root);
    document.getDocumentCatalog().setDocumentOutline(outlines);
    List<OutlineItem> flat = OutlineUtils.getFlatOutline(document);
    assertEquals(2, flat.size());
    assertEquals("child2", flat.get(0).title);
}