docs: protected void merge(List<? extends ConfigElement> elements) {
          if (elements.size() > 1) {
              Collections.sort(elements, ConfigElementComparator.INSTANCE);
          }
  
          ConfigElement[] elementArray = elements.toArray(new ConfigElement[elements.size()]);
  
          LinkedList<ConfigElement> flattened = new LinkedList<ConfigElement>();
          flattened.add(elementArray[elements.size() - 1]);
          for (int i = (elements.size() - 1); i > 0; i--) {
              ConfigElement element = new SimpleElement(elementArray[i - 1]);
              ConfigElement previous = flattened.getLast();
              if (element.getDocumentLocation().equals(previous.getDocumentLocation())) {
                  // Same document, just merge
                  element.override(previous);
                  flattened.removeLast();
                  flattened.add(element);
              } else if (previous.getParentDocumentLocation() != null && previous.getParentDocumentLocation().equals(element.getDocumentLocation())) {
                  // 'element' is in the immediate parent document of 'previous'. Just override using the merge behavior that's already specified
                  // on 'previous'
                  element.override(previous);
                  flattened.removeLast();
                  flattened.add(element);
              } else if (previous.docLocationStack.contains(element.getDocumentLocation())) {
                  // If 'element' is in the hierarchy that included 'previous', 'previous' needs to use the merge behavior specified
                  // in the include statement in the document that contains 'element'.
                  int idx = previous.docLocationStack.indexOf(element.getDocumentLocation());
                  previous.mergeBehavior = previous.behaviorStack.get(idx + 1);
                  element.override(previous);
                  flattened.removeLast();
                  flattened.add(element);
              } else {
                  // Conflicting element not in stack, add for later merging
                  flattened.add(element);
  
              }
          }
  
          for (int i = flattened.size(); i > 0; i--) {
              override(flattened.get(i - 1));
          }
  
      }