code: public static List<? extends CmsPrincipal> filterFlag(List<? extends CmsPrincipal> principals, int flag) {
  
          Iterator<? extends CmsPrincipal> it = principals.iterator();
          while (it.hasNext()) {
              CmsPrincipal p = it.next();
              if ((p.getFlags() & flag) != flag) {
                  it.remove();
              }
          }
          return principals;
      }
docs: Filters out all principals that do not have the given flag set.<p>
  
  The given parameter list is directly modified, so the returned list is the same object as the input list.<p>
  
  @param principals the list of <code>{@link CmsPrincipal}</code> objects
  @param flag the flag for filtering
  
  @return the filtered principal list