If you're able to use :is, you could shorten it to this rule:
:is
.parent > div:is(:only-child, :not(:last-child))::after