code: public JmxTree filterTree(JmxTree tree, String filter, boolean includeChildren) {
          String nameFilter = filter.trim().toLowerCase();
          Set<DomainNode> domainNodes = new TreeSet<DomainNode>();
          
          for(JmxTreeNode domain : tree.getRoot().getChildren()) {
              Set<ObjectNode> objectNodes = new TreeSet<ObjectNode>();
              for(JmxTreeNode object : domain.getChildren()) {
                  ObjectNode objectNode = (ObjectNode) object;
                  if(objectNode.getObjectName().getCanonicalName().toLowerCase().contains(nameFilter)) {
                      if(includeChildren) {
                          Set<JmxTreeNode> objectChildren = getMatchingChildren(nameFilter, objectNode);
                          ObjectNode newNode = new ObjectNode(objectNode, replaceMatch(objectNode.getLabel(), nameFilter), objectChildren);
                          newNode.setExpand(true);
                          objectNodes.add(newNode);
                      } else {
                          objectNodes.add(new ObjectNode(objectNode, replaceMatch(objectNode.getLabel(), nameFilter)));
                      }
                     
                  } else if(includeChildren){
                      addObjectNodeChildMatch(nameFilter, objectNode, objectNodes);
                  }
              }
              if(!objectNodes.isEmpty()) {
                  DomainNode domainNode = new DomainNode(domain.getLabel(), objectNodes);
                  domainNode.setExpand(true);
                  domainNodes.add(domainNode);
              }
          }
          
          RootNode root = new RootNode(LABEL_DOMAINS, domainNodes);
          JmxTree jmxTree = new JmxTree(root);
          return jmxTree;
      }
docs: Returns a filtered tree from the supplied tree.
  
  @param tree              Tree to filter.
  @param filter            Name to filter on.
  @param includeChildren   true to include attributes, operations and notifications, false to only filter on ObjectName.
  
  @return a new Tree with the filter result.