void Search(TreeViewItem searchFromThis, string search, List <TreeViewItem> result)
        {
            if (searchFromThis == null)
            {
                throw new ArgumentException("Invalid searchFromThis: cannot be null", "searchFromThis");
            }
            if (string.IsNullOrEmpty(search))
            {
                throw new ArgumentException("Invalid search: cannot be null or empty", "search");
            }

            const int kItemDepth = 0; // tree is flattened when searching

            var stack = new Stack <int>();

            m_FrameDataView.GetItemChildren(searchFromThis.id, m_ReusableChildrenIds);
            foreach (var childId in m_ReusableChildrenIds)
            {
                stack.Push(childId);
            }

            while (stack.Count > 0)
            {
                var current = stack.Pop();

                // Matches search?
                var functionName = m_ProfilerSampleNameProvider.GetItemName(m_FrameDataView, current);
                if (functionName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    var item = AcquireFrameDataTreeViewItem(m_FrameDataView, current, kItemDepth, searchFromThis);

                    item.displayName = functionName;
                    item.sortWeight  = m_FrameDataView.GetItemColumnDataAsFloat(current, m_FrameDataView.sortColumn);

                    searchFromThis.AddChild(item);
                    result.Add(item);
                }

                m_FrameDataView.GetItemChildren(current, m_ReusableChildrenIds);
                foreach (var childId in m_ReusableChildrenIds)
                {
                    stack.Push(childId);
                }
            }

            // Sort filtered results based on HerarchyFrameData sorting settings
            var sortModifier = m_FrameDataView.sortColumnAscending ? 1 : -1;

            result.Sort((_x, _y) => {
                var x = _x as FrameDataTreeViewItem;
                var y = _y as FrameDataTreeViewItem;
                if ((x == null) || (y == null))
                {
                    return(0);
                }

                int retVal;
                if (x.sortWeight != y.sortWeight)
                {
                    retVal = x.sortWeight < y.sortWeight ? -1 : 1;
                }
                else
                {
                    retVal = EditorUtility.NaturalCompare(x.displayName, y.displayName);
                }

                return(retVal * sortModifier);
            });
        }