diff --git a/src/main/java/org/jsoup/nodes/Node.java b/src/main/java/org/jsoup/nodes/Node.java index 40c9b16a1e..60f9942007 100644 --- a/src/main/java/org/jsoup/nodes/Node.java +++ b/src/main/java/org/jsoup/nodes/Node.java @@ -449,11 +449,10 @@ public Node wrap(String html) { } private Element getDeepChild(Element el) { - List children = el.children(); - if (children.size() > 0) - return getDeepChild(children.get(0)); - else - return el; + while (el.childrenSize() > 0) { + el = el.childElementsList().get(0); + } + return el; } void nodelistChanged() {