```Java
return (input == null) ? false : (Objects.equal(input.getParent(), ancestor) || apply(input.getParent()));
```