internal static bool Duplicate(this TrackAsset track, PlayableDirector director, TimelineAsset destinationTimeline = null)
        {
            bool result;

            if (track == null)
            {
                result = false;
            }
            else
            {
                if (destinationTimeline == track.timelineAsset)
                {
                    destinationTimeline = null;
                }
                TimelineAsset timelineAsset = track.parent as TimelineAsset;
                TrackAsset    trackAsset    = track.parent as TrackAsset;
                if (timelineAsset == null && trackAsset == null)
                {
                    Debug.LogWarning("Cannot duplicate track because it is not parented to known type");
                    result = false;
                }
                else
                {
                    PlayableAsset playableAsset = destinationTimeline ?? track.parent;
                    TrackAsset    trackAsset2   = TimelineHelpers.Clone(playableAsset, track, director);
                    TrackExtensions.RecursiveSubtrackClone(track, trackAsset2, director);
                    Undo.RegisterCreatedObjectUndo(trackAsset2, "Duplicate");
                    TimelineCreateUtilities.SaveAssetIntoObject(trackAsset2, playableAsset);
                    TimelineUndo.PushUndo(playableAsset, "Duplicate");
                    if (destinationTimeline != null)
                    {
                        destinationTimeline.AddTrackInternal(trackAsset2);
                    }
                    else if (timelineAsset != null)
                    {
                        TrackExtensions.ReparentTracks(new List <TrackAsset>
                        {
                            trackAsset2
                        }, timelineAsset, track, false);
                    }
                    else
                    {
                        trackAsset.AddChildAfter(trackAsset2, track);
                    }
                    result = true;
                }
            }
            return(result);
        }