code: public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
          DiscoverItems items = new DiscoverItems();
  
          if (nodeId != null)
              items.setNode(nodeId);
          items.setTo(pubSubService);
          DiscoverItems nodeItems = connection().createStanzaCollectorAndSend(items).nextResultOrThrow();
          return nodeItems;
      }
docs: Get all the nodes that currently exist as a child of the specified
  collection node.  If the service does not support collection nodes
  then all nodes will be returned.
  
  To retrieve contents of the root collection node (if it exists),
  or there is no root collection node, pass null as the nodeId.
  
  @param nodeId - The id of the collection node for which the child
  nodes will be returned.
  @return {@link DiscoverItems} representing the existing nodes
  @throws XMPPErrorException
  @throws NoResponseException if there was no response from the server.
  @throws NotConnectedException
  @throws InterruptedException