OutlineSpan nextSection(Node after) { for (Leaf l = after.getNextLeaf(); l != null; l = l.getNextLeaf()) { for (int i = 0, imax = l.sizeSticky(); i < imax; i++) { Mark m = l.getSticky(i); Object owner = m.getOwner(); if (owner instanceof OutlineSpan && ((OutlineSpan) owner).getStart() == m) { return (OutlineSpan) owner; // System.out.println("found next active = "+l.getNextLeaf()+", owner="+owner); } } } return null; }