This paper develops a balancing algorithm capable of attenuating charge, temperature, and other types of heterogeneity between cells within a lithium-ion battery pack. Cell-to-cell heterogeneity is known to negatively impact pack performance and reduce pack lifespan, and several balancing algorithms exist to mitigate this impact. These algorithms control cell currents and remove state of charge (SOC), state of health (SOH) and temperature imbalances, extending pack lifespan. However, the literature currently lacks a formalized method for removal of multiple types of heterogeneity that is scalable for different pack sizes. This paper addresses this gap by developing a balancing algorithm which is (i) general with respect to battery model selection and heterogeneity types and (ii) easily scalable to different pack sizes without increasing computational complexity. To design the algorithm, a linear time-varying (LTV) model representative of heterogeneity within the battery pack is presented. A linear quadratic regulator (LQR) is applied to this heterogeneity model, providing a systematic method to determine controller gains for the balancing currents. The block diagonal matrices of the LTV model prove advantageous, and allow the LQR problem's solution to be independent of the pack size. The novel balancing algorithm is validated through simulation using a realistic electro-thermal model with heterogeneity in charge, temperature, and other electrochemical states. This case study exemplifies the effectiveness of the balancing algorithm to eliminate multiple types of heterogeneity.