code: private static void collectChoiceEntries(
          CmsType startType,
          boolean startingAtChoiceAttribute,
          CmsChoiceMenuEntryBean currentEntry) {
  
          if (startingAtChoiceAttribute || startType.isChoice()) {
              CmsType choiceType = startingAtChoiceAttribute
              ? startType
              : startType.getAttributeType(CmsType.CHOICE_ATTRIBUTE_NAME);
              for (String choiceName : choiceType.getAttributeNames()) {
                  CmsChoiceMenuEntryBean subEntry = currentEntry.addChild(choiceName);
                  CmsType includedType = choiceType.getAttributeType(choiceName);
                  collectChoiceEntries(includedType, false, subEntry);
              }
          }
      }
docs: Recursive helper method to create a tree structure of choice menu entries for a choice type.<p>
  
  @param startType the type from which to start
  @param startingAtChoiceAttribute true if the recursion starts at a synthetic choice attribute
  @param currentEntry the current menu entry bean