def _get_linked_doctypes(doctype):
	ret = {}

	# find fields where this doctype is linked
	ret.update(get_linked_fields(doctype))

	ret.update(get_dynamic_linked_fields(doctype))

	# find links of parents
	links = frappe.db.sql("""select dt from `tabCustom Field`
		where (fieldtype="Table" and options=%s)""", (doctype))
	links += frappe.db.sql("""select parent from tabDocField
		where (fieldtype="Table" and options=%s)""", (doctype))

	for dt, in links:
		if not dt in ret:
			ret[dt] = {"get_parent": True}

	for dt in ret.keys():
		try:
			doctype_module = load_doctype_module(dt)
		except __HOLE__:
			# in case of Custom DocType
			continue

		if getattr(doctype_module, "exclude_from_linked_with", False):
			del ret[dt]

	return ret
dataset/ETHPy150Open frappe/frappe/frappe/desk/form/linked_with.py/_get_linked_doctypes