// Calculate the path to this element for debugging.
Node parent = node;
Stack stack = new ArrayListStack();
do {
stack.push(parent);
parent = parent.getParent();
} while (parent != null);
// Remove the fake parent node if there is one.
Node top = (Node) stack.peek();