A general framework for multistage mean-variance post-tax optimization