docs: public CmsSearchParameters restrict(CmsSearchParameters restriction) {
  
          // append queries
          StringBuffer query = new StringBuffer(256);
          if (getQuery() != null) {
              // don't blow up unnecessary closures (if CmsSearch is reused and restricted several times)
              boolean closure = !getQuery().startsWith("+(");
              if (closure) {
                  query.append("+(");
              }
              query.append(getQuery());
              if (closure) {
                  query.append(")");
              }
          }
          if (restriction.getQuery() != null) {
              // don't let Lucene max terms be exceeded in case someone reuses a CmsSearch and continuously restricts
              // query with the same restrictions...
              if (query.indexOf(restriction.getQuery()) < 0) {
                  query.append(" +(");
                  query.append(restriction.getQuery());
                  query.append(")");
              }
          }
  
          // restrict fields
          List<String> fields = null;
          if ((m_fields != null) && (m_fields.size() > 0)) {
              if ((restriction.getFields() != null) && (restriction.getFields().size() > 0)) {
                  fields = ListUtils.intersection(m_fields, restriction.getFields());
              } else {
                  fields = m_fields;
              }
          } else {
              fields = restriction.getFields();
          }
  
          // restrict roots
          List<String> roots = null;
          if ((m_roots != null) && (m_roots.size() > 0)) {
              if ((restriction.getRoots() != null) && (restriction.getRoots().size() > 0)) {
                  roots = ListUtils.intersection(m_roots, restriction.getRoots());
                  // TODO: This only works if there are equal paths in both parameter sets - for two distinct sets
                  //       all root restrictions are dropped with an empty list.
              } else {
                  roots = m_roots;
              }
          } else {
              roots = restriction.getRoots();
          }
  
          // restrict categories
          List<String> categories = null;
          if ((m_categories != null) && (m_categories.size() > 0)) {
              if ((restriction.getCategories() != null) && (restriction.getCategories().size() > 0)) {
                  categories = ListUtils.intersection(m_categories, restriction.getCategories());
              } else {
                  categories = m_categories;
              }
          } else {
              categories = restriction.getCategories();
          }
  
          // restrict resource types
          List<String> resourceTypes = null;
          if ((m_resourceTypes != null) && (m_resourceTypes.size() > 0)) {
              if ((restriction.getResourceTypes() != null) && (restriction.getResourceTypes().size() > 0)) {
                  resourceTypes = ListUtils.intersection(m_resourceTypes, restriction.getResourceTypes());
              } else {
                  resourceTypes = m_resourceTypes;
              }
          } else {
              resourceTypes = restriction.getResourceTypes();
          }
  
          // create the new search parameters
          CmsSearchParameters result = new CmsSearchParameters(
              query.toString(),
              fields,
              roots,
              categories,
              resourceTypes,
              m_calculateCategories,
              m_sort);
          result.setIndex(getIndex());
          return result;
      }