DefaultMutableTreeNode (String languageId) { DefaultMutableTreeNode find = TreeUtil.findNode(myRoot, n -> n instanceof LangTreeNode && languageId.equals(((LangTreeNode)n).getLanguageId())); if (find != null) { return find; } Language language = Language.findLanguageByID(languageId); String languageName = language != null ? language.getDisplayName() : languageId; CheckedTreeNode languageNode = new LangTreeNode(languageName, languageId); myRoot.add(languageNode); return languageNode; }