Fail-safe processing of Outlines without Parent link
Background
As stipulated in the PDF specification, an outline item is required to have a parent link. The parent of a top-level item is the outline dictionary itself.
PDFs generated using iText conform exactly to the above requirement. iText's logic also expect PDFs being processed using iText products to adhere to the same rule. However, some PDF processors break this rule by generating empty Parent directories, rather than including valid Parent links in their Outlines.
This has the result of iText throwing non-descriptive errors (a NPE, and in other cases entering into an endless loop) when performing operations like merging PDF or copying PDF pages.
In the iText 7.2.1 release iText ignores the Parent links in the PDF; instead, it follows the hierarchy implied by First links. By doing so, iText ensures that missing links to parent Outlines are added in resulting PDFs.
Code-Snippet: