private bool IsSomeParentLinked( INode sourceNode, INode itsChildNode) { // Is any of these children actually a parent of node in question? var otherChildren = new HashSet <INode>(sourceNode.Children); otherChildren.Remove(itsChildNode); // The whole parent tree of the particular child node in question. We don't go earlier than the source node. IEnumerable <INode> parents = _walker.EnumerateAllParentsBreadthFirst(itsChildNode, dontGoEarlierThan: sourceNode); // Is any of them linked from other children of source node? bool someParentIsLinked = parents.Any(otherChildren.Contains); return(someParentIsLinked); }