def METHOD_NAME(mesh: Mesh, dim: int, entities: typing.Optional[npt.NDArray[np.int32]] = None,
            padding: float = 0.0) -> BoundingBoxTree:
    """Create a bounding box tree for use in collision detection.
    Args:
        mesh: The mesh.
        dim: Dimension of the mesh entities to build bounding box for.
        entities: List of entity indices (local to process). If not
            supplied, all owned and ghosted entities are used.
        padding: Padding for each bounding box.
    Returns:
        Bounding box tree.
    """
    map = mesh.topology.index_map(dim)
    if map is None:
        raise RuntimeError(f"Mesh entities of dimension {dim} have not been created.")
    if entities is None:
        entities = np.arange(map.size_local + map.num_ghosts, dtype=np.int32)
    dtype = mesh.geometry.x.dtype
    if dtype == np.float32:
        return BoundingBoxTree(_cpp.geometry.BoundingBoxTree_float32(mesh._cpp_object, dim, entities, padding))
    elif dtype == np.float64:
        return BoundingBoxTree(_cpp.geometry.BoundingBoxTree_float64(mesh._cpp_object, dim, entities, padding))
    else:
        raise NotImplementedError(f"Type {dtype} not supported.")