code: private Map<String, Set<String>> toExpandMap(String[] expands) {
      if (expands != null) {
        Map<String, Set<String>> expandMap = new HashMap<>();
        for (String expand : expands) {
          // validate
          Matcher matcher = PATTERN_EXPANDS.matcher(expand);
          if (!matcher.matches()) throw new MolgenisDataException("invalid expand value: " + expand);
  
          // for partial expands, create set
          expand = matcher.group(1);
          String attrsStr = matcher.group(2);
          Set<String> attrSet;
          if (attrsStr != null && !attrsStr.isEmpty()) {
            attrSet = new HashSet<>();
            for (String attr : attrsStr.split(";")) {
              attrSet.add(attr.toLowerCase());
            }
          } else attrSet = null;
  
          expandMap.put(expand.toLowerCase(), attrSet);
        }
        return expandMap;
      }
      return null;
    }
docs: expand is of form 'attr1', 'entity1[attr1]', 'entity1[attr1;attr2]'
  
  @return map from lower case expand names to a attribute set