// remove the SkeletonNodes that do not have bone associate and that have ChildBonesCount equal to 0.
 private void RemoveNodesWithoutBones(SkeletonNode skeletonNode)
 {
     if (skeletonNode.AssimpBone == null && skeletonNode.ChildBonesCount == 0)
     {
         // Delete this bone
         var parent = skeletonNode.Parent;
         if (parent != null)
         {
             parent.Children.Remove(skeletonNode);
         }
     }
     else
     {
         for (var i = skeletonNode.Children.Count - 1; i >= 0; i--)
         {
             RemoveNodesWithoutBones(skeletonNode.Children[i]);
         }
     }
 }
        private SkeletonNode GenerateSkeleton(Node node, SkeletonNode parentSkeletonNode, ref int boneNodesLeftToGenerate)
        {
            if (node == null)
            {
                return(null);
            }

            SkeletonNode newlyCreatedSkeletonNode;

            // Bones and Nodes are "connected" with having the same name
            var boneIndex = Array.IndexOf(_allBoneNames, node.Name);

            if (boneIndex >= 0)
            {
                var assimpBone = AssimpMesh.Bones[boneIndex];
                boneNodesLeftToGenerate--; // Reduce the number of SkeletonNode that we still need to create

                newlyCreatedSkeletonNode = new SkeletonNode(node, assimpBone, parentSkeletonNode, boneIndex: SkeletonNodes.Count);
            }
            else
            {
                newlyCreatedSkeletonNode = new SkeletonNode(node, null, parentSkeletonNode, -1);
            }

            SkeletonNodes.Add(newlyCreatedSkeletonNode);

            if (node.HasChildren && boneNodesLeftToGenerate > 0)
            {
                for (var i = 0; i < node.ChildCount; i++)
                {
                    var childBone = GenerateSkeleton(node.Children[i], newlyCreatedSkeletonNode, ref boneNodesLeftToGenerate);

                    if (childBone != null)
                    {
                        newlyCreatedSkeletonNode.Children.Add(childBone);
                    }
                }
            }

            return(newlyCreatedSkeletonNode);
        }