code: private void addConnectionDescendants(Collection<Connection> connections,
              List<ObjectPermission.Type> permissions)
          throws GuacamoleException {
  
          // If no connections, nothing to do
          if (connections.isEmpty())
              return;
  
          // Build lists of sharing profile identifiers for retrieval
          Collection<String> identifiers = new ArrayList<String>();
          for (Connection connection : connections)
              identifiers.addAll(connection.getSharingProfileIdentifiers());
  
          // Filter identifiers based on permissions, if requested
          if (permissions != null && !permissions.isEmpty())
              identifiers = sharingProfilePermissions.getAccessibleObjects(
                      permissions, identifiers);
  
          // Retrieve and add all associated sharing profiles
          if (!identifiers.isEmpty()) {
              Collection<SharingProfile> sharingProfiles = sharingProfileDirectory.getAll(identifiers);
              addSharingProfiles(sharingProfiles);
          }
  
      }
docs: Adds all descendant sharing profiles of the given connections to their
  corresponding primary connections already stored under root.
  
  @param connections
  The connections whose descendant sharing profiles should be added to
  the tree.
  
  @param permissions
  If specified and non-empty, limit added sharing profiles to only
  those for which the current user has any of the given
  permissions. Otherwise, all visible sharing profiles are added.
  
  @throws GuacamoleException
  If an error occurs while retrieving the descendants.