A general extending and constraining procedure for linear iterative methods