nodes: add ancestorsWhile

PTAL