def get_parents(self, context):
		# already set
		if context.parents:
			return context.parents

		home_page = get_home_page()

		parents = []
		me = self
		while me:
			_parent_field = me.website.parent_website_route_field
			_parent_val = me.get(_parent_field) if _parent_field else None

			# if no parent and not home page, then parent is home page
			if not _parent_val and me.get_route() != home_page:
				# parents.append(frappe._dict(name=home_page, title=get_route_info(home_page).title))
				break

			elif _parent_val:
				df = me.meta.get_field(_parent_field)
				if not df:
					break
				parent_doc = frappe.get_doc(df.options, _parent_val)

				if not parent_doc.website_published():
					break

				if parent_doc:
					parent_info = frappe._dict(name = parent_doc.get_route(),
						title= parent_doc.get(parent_doc.website.page_title_field or "name"))
				else:
					parent_info = frappe._dict(name=self.parent_website_route,
						title=self.parent_website_route.replace("_", " ").title())

				if parent_info.name in [p.name for p in parents]:
					raise frappe.ValidationError, "Recursion in parent link"

				parents.append(parent_info)
				me = parent_doc
			else:
				# parent route is a page e.g. "blog"
				if me.get("parent_website_route"):
					page_route = get_page_route(me.parent_website_route)
					if page_route:
						parents.append(frappe._dict(name = page_route.name,
							title=page_route.page_title))
				me = None

		parents.reverse()
		return parents
dataset/ETHPy150Open frappe/frappe/frappe/website/website_generator.py/WebsiteGenerator.get_parents/original