Main { public static void main(String args[]) throws Exception {{ XPath m = XPath.parse(System.in); // m.display(); ClassGraph cgfull = new ClassGraph(true, false); ClassGraph cg = new ClassGraph(cgfull, "from XPath bypassing -> *,tail,* to *"); System.out.println("done"); String parents = "from XPath bypassing ->*,parent,*" + "to {UnaryCompound, BinaryCompound}"; cg.traverse(m,parents,new ParentSettingVisitor()); m.display(); }} } ParentSettingVisitor { {{ public void start() {} public void before (BinaryCompound host) { host.get_arg1().set_parent(host); host.get_arg2().set_parent(host); } public void before (UnaryCompound host) { host.get_arg1().set_parent(host); } }} } XPath { void display() bypassing -> *,parent,* to * (DisplayVisitor); }