Check if 3D grid is filled from top to bottom
I'd first write a helper function bucket_fill_2d() that takes a slice with material info and, given a starting index (i,j), bucket fills the material like in any old drawing program.

Introduce an empty Boolean array connected of the shape. 
Set the bottom slice True wherever the material array's bottom slice is True.
Then go up one step up and bucket_fill_2d(), starting with every connected (i,j) from the previous step.
Repeat (3) until you reach the top.
Check if anything is connected at the top slice.

Note that trimesh, as the name suggests, only supports triangular cells.
I have a 3D grid for representing shapes/meshes which is represented in python using an ndarray(20,20,20) of type bool. Each element in the grid represents the presence or absence of material. I want to be able to check if a given grid represents a shape that is connected all the way from the top of the grid to the bottom. I want to be able to discard those that are either disconnected or not occupying continuous series of cells from top of the grid to the bottom. 
At a later stage I convert the grids into meshes using trimesh. Is there any way to identify the above either directly in python or through trimesh?