code: public static IndexPlanner both( final IndexPlanner planner1,
                                       final IndexPlanner planner2 ) {
          if (planner1 == null) return planner2;
          if (planner2 == null) return planner1;
          return new IndexPlanner() {
  
              @Override
              public void applyIndexes( QueryContext context,
                                        IndexCostCalculator calculator ) {
                  RuntimeException error = null;
                  try {
                      planner1.applyIndexes(context, calculator);
                  } catch (RuntimeException e) {
                      error = e;
                  } finally {
                      try {
                          planner2.applyIndexes(context, calculator);
                      } catch (RuntimeException e) {
                          if (error == null) error = e;
                      } finally {
                          if (error != null) throw error;
                      }
                  }
              }
          };
      }
docs: Utility that returns an {@link IndexPlanner} implementation that delegates to the first planner and then to the second
  planner. If only one of the supplied planner instances is not null, then this method will simply return the non-null
  planner.
  
  @param planner1 the first planner
  @param planner2 the second planner
  @return the composite planner, or null when both {@code planner1} and {@code planner2} are null