boolean (Object parent, Object child) { Object eachParent = child; while (eachParent != null) { if (parent.equals(eachParent)) return true; eachParent = myUi.getTreeStructure().getParentElement(eachParent); } return false; }