function isOrphan(block) {
  // If the parent is an orphan block, this block should also be considered
  // an orphan so it cannot be manually re-enabled.
  const parent = /** @type {Blockly.BlockSvg} */ (block.getParent());
  if (parent && isOrphan(parent)) {
    return true;
  }
  return !parent && !!(block.outputConnection || block.previousConnection);
}
A block is an orphan if its parent is an orphan, or if it doesn't have a
parent but it does have a previous or output connection (so it expects to be
attached to something). This means all children of orphan blocks are also
orphans and cannot be manually re-enabled.
@param {!Blockly.BlockSvg} block Block to check.
@returns {boolean} Whether the block is an orphan.