Trigrad.DataTypes.Sample.depthSelect C# (CSharp) Method

depthSelect() private static method

private static depthSelect ( Sample sample, int depth, List parents = null ) : List
sample Sample
depth int
parents List
return List
        private static List<Sample> depthSelect(Sample sample, int depth, List<Sample> parents = null)
        {
            if (depth <= 0)
                return new List<Sample>();

            List<Sample> samples = new List<Sample>();
            foreach (var child in sample.Samples)
            {
                if (parents != null && parents.Contains(child))
                    continue;

                samples.Add(child);
                var result = depthSelect(child, depth - 1, samples);

                samples.AddRange(result);
            }
            return samples;
        }