Package CreatePackageInfo(PackageDependency dependency, IEnumerable<IPackageInfo> resolvedPackages, IEnumerable<IPackageInfo> lockedPackages, bool includeChildren, Stack<string> recursionDefender)
 {
     var packageInfo = new Package(
         resolvedPackages.FirstOrDefault(
             pack => pack.Name.EqualsNoCase(dependency.Name)),
         dependency.ToString(),
         lockedPackages.Any(x => x.Name.EqualsNoCase(dependency.Name)));
     if (!includeChildren) return packageInfo;
     if (recursionDefender.ContainsNoCase(dependency.Name))
         packageInfo.Children = Truncated;
     else
     {
         recursionDefender.Push(dependency.Name);
         packageInfo.Children = (
                                    packageInfo.PackageInfo.Dependencies.Select(
                                        dep => CreatePackageInfo(dep, resolvedPackages, lockedPackages, includeChildren, recursionDefender)))
             .ToList();
         recursionDefender.Pop();
     }
     return packageInfo;
 }