Error if page is descendant of ancestor


I’ve got a structure setup that looks like this:
- products
– product A
— product A1
---- product A11
---- product A12
— product A2
– product B

Now if I check if product A11 is a descendant of products
if ($page->isDescendantOf('products')):
everything is fine.

But if I check if the same product A11 is a descendant of product A I get an error:
Call to a member function id() on boolean

Does anybody have an idea?
Thanks in advance!


The problem is I used:
if ($page->isDescendantOf('product A')):

But instead the argument should be:
if ($page->isDescendantOf('products/product A')):