code: private boolean canContain(
        int child, int container, int containerIndexOnStack) {
      Preconditions.checkArgument(containerIndexOnStack >= 0);
      int anc = container;
      int ancIndexOnStack = containerIndexOnStack;
      while (true) {
        if (METADATA.canContain(anc, child)) {
          return true;
        }
        if (!TRANSPARENT.get(anc)) {
          return false;
        }
        if (ancIndexOnStack == 0) {
          return METADATA.canContain(BODY_TAG, child);
        }
        --ancIndexOnStack;
        anc = openElements.get(ancIndexOnStack);
      }
    }
docs: Takes into account transparency when figuring out what
  can be contained.