The Twig Backlink extension builds a list of URL of the parents of the node based on the field name passed in the Twig twig_backlink extension parameter.
Move array definitions out of code and organize them with the Y module. Y has much of the functionality of CTools, Features, Views, Panels, and Page Manage built-in and lightning-fast!