docs: private int bestSurroundingSet(int index, int length, int... valid) {
          int option1 = set[index - 1];
          if (index + 1 < length) {
              // we have two options to check
              int option2 = set[index + 1];
              if (contains(valid, option1) && contains(valid, option2)) {
                  return Math.min(option1, option2);
              } else if (contains(valid, option1)) {
                  return option1;
              } else if (contains(valid, option2)) {
                  return option2;
              } else {
                  return valid[0];
              }
          } else {
              // we only have one option to check
              if (contains(valid, option1)) {
                  return option1;
              } else {
                  return valid[0];
              }
          }
      }