private static ISet<int> GetInnerStreams( int fromStream, ISet<int> toStreams, OuterInnerDirectionalGraph outerInnerGraph, InnerJoinGraph innerJoinGraph, ISet<int> completedStreams) { ISet<int> innerStreams = new HashSet<int>(); foreach (var toStream in toStreams) { if (outerInnerGraph.IsInner(fromStream, toStream)) { // if the to-stream, recursively, has an inner join itself, it becomes a required stream and not optional var hasInnerJoin = false; if (!innerJoinGraph.IsEmpty()) { var doNotUseStreams = new HashSet<int>(completedStreams); completedStreams.Add(fromStream); hasInnerJoin = RecursiveHasInnerJoin( toStream, outerInnerGraph, innerJoinGraph, doNotUseStreams); } if (!hasInnerJoin) { innerStreams.Add(toStream); } } } return innerStreams; }