public PdfObjectTreeNode getAncestor() { if (isRecursive()) { PdfObjectTreeNode node = this; while (true) { node = (PdfObjectTreeNode) node.getParent(); if (node.isIndirectReference() && node.getNumber() == getNumber()) { return node; } } } return null; }
@SuppressWarnings("unchecked") public PdfObjectTreeNode getChildNode(PdfObjectTreeNode node, PdfName key) { Enumeration<PdfObjectTreeNode> children = node.breadthFirstEnumeration(); PdfObjectTreeNode child; while (children.hasMoreElements()) { child = children.nextElement(); if (child.isDictionaryNode(key)) { if (child.isIndirectReference()) { expandNode(child); child = (PdfObjectTreeNode) child.getFirstChild(); } expandNode(child); return child; } } return null; }