/**
   * Get itemset for a selection control given either directly or by id. If the control is null or
   * non-relevant, lookup by id takes place and the control must have a static itemset or otherwise
   * null is returned.
   *
   * @param pipelineContext current pipeline context
   * @param containingDocument current containing document
   * @param control control from which to obtain itemset (may be null if control has a static
   *     itemset)
   * @param prefixedId prefixed id of control from which to obtain itemset (if control is null)
   * @return itemset or null if it is not possible to obtain it
   */
  public static Itemset getInitialItemset(
      PipelineContext pipelineContext,
      XFormsContainingDocument containingDocument,
      XFormsSelect1Control control,
      String prefixedId) {

    if (control != null && control.isRelevant()) {
      // Control is there and relevant so just ask it (this will include static itemsets evaluation
      // as well)
      return control.getItemset(pipelineContext);
    } else if (isStaticItemset(containingDocument, prefixedId)) {
      // Control is not there or is not relevant, so use static itemsets
      // NOTE: This way we output static itemsets during initialization as well, even for
      // non-relevant controls
      return ((SelectionControl) containingDocument.getStaticState().getControlAnalysis(prefixedId))
          .evaluateStaticItemset();
    } else {
      // Not possible so return null
      return null;
    }
  }