/** * Traverses all the documents at and below the specified document in a * tree. Traversal is done depth first. The order of sub-document traversal * within a specific Document is unspecified (For example, a tables columns * may be traversed in any order). * * @param document the document to start at * @return stream of descendants */ @SuppressWarnings("unchecked") public static Stream<? extends Document> traverseOver(Document document) { requireNonNull(document); return Trees.traverse( document, d -> d.children(), Trees.TraversalOrder.DEPTH_FIRST_PRE ); }