getLTree :: Handler [LTree]
getLTree = do
    allLabels <- runDB $ selectList [] []
    return $ map (go allLabels) $ filter (filt Nothing) (allLabels :: [(LabelId, Label)])
  where
    filt :: Maybe LabelId -> (LabelId, Label) -> Bool
    filt x (_, y) = labelParent y == x
    go :: [(LabelId, Label)] -> (LabelId, Label) -> LTree
    go m (lid', l) = LTree lid' (labelName l) $ map (go m) $ filter (filt $ Just lid') m
getLTree :: Handler [LTree]
getLTree = do
    allLabels <- runDB $ selectList [] []
    return $ map (go allLabels) $ filter (filt Nothing) (allLabels :: [(LabelId, Label)])
  where
    filt :: Maybe LabelId -> (LabelId, Label) -> Bool
    filt x (_, y) = labelParent y == x
    go :: [(LabelId, Label)] -> (LabelId, Label) -> LTree
    go m (lid', l) = LTree lid' (labelName l) $ map (go m) $ filter (filt $ Just lid') m
getLTree = do
    allLabels <- runDB $ selectList [] []
    return $ map (go allLabels) $ filter (filt Nothing) (allLabels :: [(LabelId, Label)])
  where
    filt :: Maybe LabelId -> (LabelId, Label) -> Bool
    filt x (_, y) = labelParent y == x
    go :: [(LabelId, Label)] -> (LabelId, Label) -> LTree
    go m (lid', l) = LTree lid' (labelName l) $ map (go m) $ filter (filt $ Just lid') m