finish feature/optimize-leaves