faster tree with numpy operatio instead of iteration