code: public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
        throws RemoteException {
      // Get the InventoryService.
      InventoryServiceInterface inventoryService =
          adManagerServices.get(session, InventoryServiceInterface.class);
  
      // Get the NetworkService.
      NetworkServiceInterface networkService =
          adManagerServices.get(session, NetworkServiceInterface.class);
  
      // Get the effective root ad unit.
      String rootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
  
      // Create a statement to select only the root ad unit by ID.
      StatementBuilder statementBuilder =
          new StatementBuilder()
              .where("id = :id")
              .orderBy("id ASC")
              .limit(1)
              .withBindVariableValue("id", rootAdUnitId);
  
      AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());
  
      AdUnit effectiveRootAdUnit = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
  
      // Get all ad units.
      List<AdUnit> adUnits = getAllAdUnits(adManagerServices, session);
  
      buildAndDisplayAdUnitTree(effectiveRootAdUnit, adUnits);
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.