The nonuniform distribution of points in a point cloud and their abundant attribute information (such as colour, reflectance, and normal) result in the generation of massive data, making point cloud compression (PCC) essential for related applications. The hierarchical structure of the level of detail (LOD) in a point cloud and the corresponding predictions are commonly used in PCC, whereas the current method of LOD generation is neither content adaptive nor optimized. Targeting lossless PCC, an LOD prediction error model is proposed in this work, based on which the prediction error is minimized to obtain the optimal coding performance. As a result, the process of generating LOD is optimized, where the smallest number of LOD levels that yields the minimum attribute bitrate can be found. The proposed method is evaluated on various standard datasets under common test conditions. Experimental results show that the proposed method achieves optimal coding performance in a content-adaptive way while significantly reducing the time required for encoding and decoding, i.e., ~15.2% and ~17.3% time savings on average for distance-based LOD, and ~5.4% and ~5.1% time savings for Morton-based LOD, respectively.