Element parent = new Element("Test");
Element child = new Element("child");
parent.appendChild(child);
grandparent.appendChild(parent);
Nodes result = child.query("ancestor::*");
assertEquals(2, result.size());
assertEquals(grandparent, result.get(0));
assertEquals(parent, result.get(1));
}