@Test
public void infiniteLoop() throws IOException {

    try (PDDocument document = PDFParser.parse(SeekableSources.inMemorySeekableSourceFrom(getClass()
            .getClassLoader().getResourceAsStream("pdf/infinite_outline.pdf")))) {
        for (PDPage current : document.getPages()) {
            mapping.addLookupEntry(current, new PDPage());
        }
        PDDocumentOutline outline = new PDDocumentOutline();
        new OutlineDistiller(document).appendRelevantOutlineTo(outline, mapping);
        assertTrue(outline.hasChildren());
        
        int outlineChildCount = 0;
        for(PDOutlineItem child: outline.children()) {
            outlineChildCount++;
        }
        
        assertEquals(3, outlineChildCount);
    }
}