if (node == null) {
return null;
} else if (node == stop) {
if (node instanceof Element) {
Element element = (Element) node;
Node next = element.getHead();
if (next instanceof Element) {
Element nextElement = (Element) next;
if (KEEPTOGETHER_ELEMENT.equals(nextElement.getName())) {
return getRealNode(nextElement.getHead());
}
}
return next;
} else {
return null;
}
}
if (node instanceof Element) {
Element element = (Element) node;
if (KEEPTOGETHER_ELEMENT.equals(element.getName())) {
return getRealNode(element.getHead());
}
}
Node next = node.getNext();
if (next == null) {
Node parent = node.getParent();
if (parent != null) {
if (parent.equals(stop)) {
return null;
} else {
return getRealNode(parent.getNext());
}
} else {
return null;
}
} else if (next instanceof Element) {