code: static CancellableContext cancellableAncestor(Context parent) {
      if (parent == null) {
        return null;
      }
      if (parent instanceof CancellableContext) {
        return (CancellableContext) parent;
      }
      // The parent simply cascades cancellations.
      // Bypass the parent and reference the ancestor directly (may be null).
      return parent.cancellableAncestor;
    }
docs: Returns {@code parent} if it is a {@link CancellableContext}, otherwise returns the parent's
  {@link #cancellableAncestor}.