The method calls getAncestors().stream().findFirst(), which returns the home page of the space the page is contained in, not the parent of the page.
PS: Please let me know if you fix it, because then MY plugin will be broken.