code: public static Treenode findNodeByLabel(Treenode parent, String label, boolean create, Class<? extends Treenode> clazz,
                                             boolean caseSensitive) {
          Treenode item = null;
  
          for (BaseComponent comp : parent.getChildren()) {
              if (comp instanceof Treenode) {
                  item = (Treenode) comp;
  
                  if (caseSensitive ? item.getLabel().equals(label) : item.getLabel().equalsIgnoreCase(label)) {
                      return item;
                  }
              }
          }
  
          if (create) {
              try {
                  item = clazz.newInstance();
                  item.setLabel(label);
                  item.setHint(label);
                  parent.addChild(item);
                  return item;
              } catch (Exception e) {
                  throw MiscUtil.toUnchecked(e);
              }
          }
  
          return null;
      }
docs: Finds the node (tree item) with the specified label under the specified parent. If no node
  matches the label, one will be created.
  
  @param parent Tree node whose children are to be searched.
  @param label Label being sought (case-insensitive).
  @param create If true and the matching tree item is not found, it will be created.
  @param clazz Class of tree item to be created.
  @param caseSensitive If true, match by exact case.
  @return The node whose label matches that specified.