Background: In treatment planning, beam angle optimization (BAO) refers to the selection of a subset with a given number of beam angles from all available angles that provides the best plan quality. BAO is a NP-hard combinatorial problem. Although exhaustive search (ES) can exactly solve BAO by exploring all possible combinations, ES is very time-consuming and practically infeasible. Purpose: To the best of our knowledge, (1) no optimization method has been demonstrated that can provide the exact solution to BAO,and (2) no study has validated an optimization method for solving BAO by benchmarking with the optimal BAO solution (e.g., via ES), both of which will be addressed by this work. Methods: This work considers BAO for proton therapy,for example,the selection of 2-4 beam angles for IMPT. The optimal BAO solution is obtained via ES and serves as the ground truth. A new BAO algorithm, namely angle generation (AG) method, is proposed, and demonstrated to provide nearly-exact solutions for BAO in reference to the ES solution. AG iteratively optimizes the angular set via group-sparsity (GS) regularization, until the planning objective does not decrease further. Results: Since GS alone can also solve BAO, AG was validated and compared with GS for 2-angle brain, 3-angle lung, and 4-angle brain cases, in reference to the optimal BAO solutions obtained by ES: the AG solution had the rank (1/276, 1/2024, 4/10 626), while the GS solution had the rank (42/276, 279/2024, 4328/10 626). Conclusions: A new BAO algorithm called AG is proposed and shown to provide substantially improved accuracy for BAO from current methods with nearly-exact solutions to BAO, in reference to the ground truth of optimal BAO solution via ES.