code: function aaObtainFormattingElementEntry(p, token) {
      let formattingElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(token.tagName);
  
      if (formattingElementEntry) {
          if (!p.openElements.contains(formattingElementEntry.element)) {
              p.activeFormattingElements.removeEntry(formattingElementEntry);
              formattingElementEntry = null;
          } else if (!p.openElements.hasInScope(token.tagName)) {
              formattingElementEntry = null;
          }
      } else {
          genericEndTagInBody(p, token);
      }
  
      return formattingElementEntry;
  }
docs: Adoption agency algorithm (see: http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#adoptionAgency) ------------------------------------------------------------------ Steps 5-8 of the algorithm