docs: @Override
      @SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.NcssCount",
          "PMD.NPathComplexity" })
      public <T extends ComponentType> T attach(T child) {
          synchronized (this) {
              ComponentVertex childNode = componentVertex(child, null);
              List<Channel> attachedAsChannels = new ArrayList<>();
              synchronized (childNode) {
                  if (tree != null && tree.isStarted()) {
                      for (TreeIterator itr = new TreeIterator(childNode);
                              itr.hasNext();) {
                          attachedAsChannels.add(itr.next());
                      }
                  }
                  synchronized (tree()) {
                      if (childNode.tree == null) {
                          // Newly created, stand-alone child node
                          childNode.parent = this;
                          childNode.setTree(tree);
                          children.add(childNode);
                      } else {
                          // Attaching a tree...
                          synchronized (childNode.tree) {
                              if (childNode.parent != null) {
                                  throw new IllegalStateException(
                                      "Cannot attach a node with a parent.");
                              }
                              if (childNode.tree.isStarted()) {
                                  throw new IllegalStateException(
                                      "Cannot attach a started subtree.");
                              }
                              childNode.parent = this;
                              ComponentTree childTree = childNode.tree;
                              childNode.setTree(tree);
                              children.add(childNode);
                              tree.mergeEvents(childTree);
                          }
                      }
                      tree.clearHandlerCache();
                  }
              }
              Channel parentChan = channel();
              if (parentChan == null) {
                  parentChan = Channel.BROADCAST;
              }
              Channel childChan = childNode.channel();
              if (childChan == null) {
                  parentChan = Channel.BROADCAST;
              }
              Attached evt = new Attached(childNode.component(), component());
              if (parentChan.equals(Channel.BROADCAST)
                  || childChan.equals(Channel.BROADCAST)) {
                  fire(evt, Channel.BROADCAST);
              } else if (parentChan.equals(childChan)) {
                  fire(evt, parentChan);
              } else {
                  fire(evt, parentChan, childChan);
              }
              if (!attachedAsChannels.isEmpty()) {
                  fire(new Start(), attachedAsChannels.toArray(new Channel[0]));
              }
              return child;
          }
      }