Object referenced by PointerProperty in Python can not be deleted properly I am trying to replicate the functionality of Object Parent using the dropper select tool in Python (an image is attached for what exactly am I trying to replicate).:



For this purpose, I am using the PointerProperty to get a pointer to the object. Most of the functionalities work as expected, similar to the implementation above. However, if I delete the object (either using the keyboard shortcuts or the python method), it disappears from the 3D view but it is still present in bpy.data.objects. Moreover, the PointerProperty does not clear the object field as is the case with the original object parent field. I have tested this in Blender 2.79 and 2.81 with similar results. Any suggestions would be appreciated. 
This is the code I am using.

import bpy
bl_info = {
    "name": "Pointer Property Test",
    "author": "Mr. Potato",
    "version": (0, 1),
    "blender": (2, 79, 0)
}


class PT_test_constraint(bpy.types.Panel):
    """Add Rigid Body Properties"""
    bl_label = "TEST PROPERTIES"
    bl_idname = "addon.test_constraint"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context= "physics"

    bpy.types.Object.test_constraint_parent = bpy.props.PointerProperty(name="Parent", type=bpy.types.Object)

    def draw(self, context):

        layout = self.layout
        col = layout.column()
        col.prop_search(context.object, "test_constraint_parent", context.scene, "objects")                


def register():
    from bpy.utils import register_class
    register_class(PT_test_constraint)


def unregister():
    from bpy.utils import unregister_class
    unregister_class(PT_test_constraint)


if __name__ == "__main__":
    register()
    #unregister()
Based on the suggestion by @batFinger, I realized that if I delete the object using the keyboard shortcut or using the Python console, it is unlinked from the scene and its reference count decreases by 1. Since the pointer property still has a reference to the object, it is not removed from bpy.data.objects. Therefore, I check in my Panel draw() function (which updates automatically) if the desired object is present in the scene as follows:

if context.scene.objects.get(desired_object.name) == None:
# That means that the object has been deleted from the
# scene graph, therefore remove it explicitly
    bpy.data.objects.remove(desired_obj)


This lets me reproduce the functionality inheret to the Blender when dealing with PointerProperty Objects as mentioned in my question.