getParent() is very rarely what you want to use nowadays (we should probably discuss making it more explicitly deprecated, XWikiDocument#getParent already is deprecated)
The hierarchy of the page/document is all in its reference:
$doc.pageReference give you the reference of the current page (with page reference syntax, so / separator instead of . and no WebHome thingy)
$doc.pageReference.parent will give you the reference of its parent page
etc.
You have the same thing with $doc.documentReference, $doc.documentReference.parent, etc. but page references usually makes things a bit easier to understand since they match better how things are presented in the UI.
But until recently, getParent was correctly returning the parent created by the template. At some point (I can’t pinpoint exactly what changed), the child page started pointing back to the template. For pages created in the past, even now, when I edit them and add getParent, it correctly points to the parent. So, how can I achieve the same effect with pageReference?
And how can I get the children of the parent obtained in this way? I want to have links on the subpage that refer to other subpages, so I need to retrieve the other children of the parent.
And how to use documentTree macro for parent in this way?
I did not say it’s always different from the real parent, just that it’s not necessarily accurate, since the fact that it can point anywhere is a feature (it’s just not displayed anymore in the UI by default).
I’m not sure which “effect” you are referring to, pageReference.parent is always the parent of the page in the real hierarchy (where the page is actually stored and what the breadcrumbs show you), you cannot customize it like the legacy metadata called “parent”.
If you just want the siblings of your page, the easiest would probably be to use a query to search all the documents located in the same space as your parent (so $doc.space for example) as your document.
Ok, but the problem is that without any changes, my macro in the panels that used getParent() stopped working. Previously, it correctly pointed to its parent after being created from the template, but now it refers to the parent as Templates.XXX.WebHome. What could have happened? How, then, can I get the other siblings from the perspective of a child created from a template?