public boolean hasAncestor(Node ancestor) {
        if (parent == null) {
            return false;
        } else if (parent.equals(ancestor)) {
            return true;
        } else {
            return parent.hasAncestor(ancestor);
        }
    }
determines if the provided Node is the parent, or parent's parent, etc. of this Spatial.

@param ancestor
           the ancestor object to look for.
@return true if the ancestor is found, false otherwise.
jme3-core/src/main/java/com/jme3/scene/Spatial.java