Finding bounding box of the head model

I’m trying to find the values of the bounding box that covers the model.
But the code is very very slow. Is there a different way?

Widget = slicer.app.layoutManager().threeDWidget(0)
modelDispManager = Widget.threeDView().displayableManagerByClassName("vtkMRMLModelDisplayableManager")

k=1500; minx=k; miny=k; maxx=0; maxy=0;
for i in range(k):
    for j in range(k):
        if modelDisplayableManager.Pick(i,j) and modelDisplayableManager.GetPickedNodeID():
            if i<miny: miny=i;
            if j<minx: minx=j;
            if i>maxy: maxy=i;
            if j>maxx: maxx=j;
print("x:",[minx,maxx],"  y:",[miny,maxy])