entrytree_collapse_p :: Entry a => [EntryTree a] -> Loc -> Maybe [EntryTree a]
entrytree_collapse_p et loc@(Loc cl) = entrytree_map_path f et loc
    where
        f e Nothing (Loc ll) | (length cl - length ll) <= 1 =
            case entrytree_expanded e of
                True -> Just [e{entrytree_expanded = False}]
                False -> Nothing
        f e Nothing _ = Nothing
        f e (Just nch) _ =
            Just [e{entrytree_children=nch}]
entrytree_collapse_p :: Entry a => [EntryTree a] -> Loc -> Maybe [EntryTree a]
entrytree_collapse_p et loc@(Loc cl) = entrytree_map_path f et loc
    where
        f e Nothing (Loc ll) | (length cl - length ll) <= 1 =
            case entrytree_expanded e of
                True -> Just [e{entrytree_expanded = False}]
                False -> Nothing
        f e Nothing _ = Nothing
        f e (Just nch) _ =
            Just [e{entrytree_children=nch}]
entrytree_collapse_p et loc@(Loc cl) = entrytree_map_path f et loc
    where
        f e Nothing (Loc ll) | (length cl - length ll) <= 1 =
            case entrytree_expanded e of
                True -> Just [e{entrytree_expanded = False}]
                False -> Nothing
        f e Nothing _ = Nothing
        f e (Just nch) _ =
            Just [e{entrytree_children=nch}]