private static IEnumerable<ITree> DoWorkForFindAll( ITree nodeToSearch, ITree target, bool partialMatch ) { if ( ( partialMatch && nodeToSearch.equalsTreePartial( target ) ) || ( !partialMatch && nodeToSearch.equalsTree( target ) ) ) { yield return nodeToSearch; } for ( int i = 0; i < nodeToSearch.ChildCount; i++ ) { ITree child = nodeToSearch.GetChild( i ); if ( child != null ) { foreach ( ITree tree in DoWorkForFindAll( child, target, partialMatch ) ) yield return tree; } } }