refactor ancestor checking any_instance observer to lambda