function findInvalidNest(tree) {
    /**
     * Node types that are considered "blocks".
     */
    const blocks = ['paragraph', 'heading', 'code', 'blockquote', 'list', 'table', 'thematicBreak'];

    /**
     * Node types that can contain "block" nodes as direct children. We check
     */
    const canContainBlocks = ['root', 'blockquote', 'listItem', 'tableCell'];

    let invalidNest;

    visitParents(tree, (node, parents) => {
      const parentType = !isEmpty(parents) && last(parents).type;
      const isInvalidNest = blocks.includes(node.type) && !canContainBlocks.includes(parentType);

      if (isInvalidNest) {
        invalidNest = concat(parents, node);
        return false;
      }
    });

    return invalidNest;
  }
visitParents uses unist-util-visit-parent to check every node in the
tree while having access to every ancestor of the node. This is ideal
for determining whether a block node has an ancestor that should not
contain a block node. Note that it operates in a mutable fashion.