removing mutable state from directed graph ancestors/descendants