In general
For purposes of this chapter, any tax of a foreign country or possession of the United States which is paid or accrued with respect to any distribution from a corporation—
(A)#
to the extent that such distribution is attributable to periods during which such corporation is a possessions corporation, and
(B)#
(i) if a dividends received deduction is allowable with respect to such distribution under part VIII of subchapter B, or
(ii) to the extent that such distribution is received in connection with a liquidation or other transaction with respect to which gain or loss is not recognized,
(B)(i)#
if a dividends received deduction is allowable with respect to such distribution under part VIII of subchapter B, or
(B)(ii)#
to the extent that such distribution is received in connection with a liquidation or other transaction with respect to which gain or loss is not recognized,
shall not be treated as income, war profits, or excess profits taxes paid or accrued to a foreign country or possession of the United States, and no deduction shall be allowed under this title with respect to any amount so paid or accrued.