Creating a structured category list in F#
Here is an optimized version that I have discovered:

let getStructuredCategories ()  =

let fullList = allCategoriesAndDetails () 

let parentList () =
    allCategoriesAndDetails ()
    |&gt; Seq.filter (fun p -&gt; p.ParentStructureId = NotValid)

let rec toTree (fullList': seq&lt;CategoryStructure&gt;) (parent: CategoryStructure) =

    fullList'
    |&gt; Seq.filter (fun x -&gt; x.ParentStructureId = parent.Id)
    |&gt; Seq.map (fun x -&gt; 
                    {
                        Category = x;
                        SubCategories =
                            toTree fullList' x
                    })
seq {
    for row in parentList () do
    yield {

        Category = row;
        SubCategories = toTree fullList row    
    }

}


Can someone else do better?