Returning neighboring objects?

I am scripting and all I need to do is have blender return a Boolean if one object is a neighbor of another.

I’ll have to do more research on KDTree. But other than that, is that all that there is?