static class SdtPrFinder extends CallbackImpl { List sdtPrList = new ArrayList(); @Override public List apply(Object o) { if (o instanceof org.docx4j.wml.SdtBlock || o instanceof org.docx4j.wml.SdtRun || o instanceof org.docx4j.wml.CTSdtRow || o instanceof org.docx4j.wml.CTSdtCell ) { SdtPr sdtPr = OpenDoPEHandler.getSdtPr(o); if (sdtPr!=null) { sdtPrList.add(sdtPr); } } return null; } } SdtPrFinder sdtPrFinder = new SdtPrFinder(); new TraversalUtil(paragraphs, sdtPrFinder); for ( SdtPr sdtPr : sdtPrFinder.sdtPrList) { ...