boolean (@NotNull Object element, @NotNull DefaultMutableTreeNode node) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); Object parentElement = getElementFor(parent); if (!isInStructure(parentElement)) return false; if (parent instanceof ElementNode) { return ((ElementNode)parent).isValidChild(element); } for (int i = 0; i < parent.getChildCount(); i++) { TreeNode child = parent.getChildAt(i); Object eachElement = getElementFor(child); if (element.equals(eachElement)) return true; } return false; }