entrytree_map_maybe_ f (e2:et) rrr@(r:rr) =
    case (e2n, etn) of
        (Nothing, Nothing) -> Nothing
        (Nothing, Just etn) -> Just (e2:etn)
        (Just e2n, Nothing) -> Just (e2n++et)
        (Just e2n, Just etn) -> Just (e2n++etn)
    where
        nch = entrytree_map_maybe_ f (entrytree_children e2) (0:rrr)
        e2n = f e2 nch (Loc $ reverse rrr)
        etn = entrytree_map_maybe_ f et ((r+1):rr)
entrytree_map_maybe_ f (e2:et) rrr@(r:rr) =
    case (e2n, etn) of
        (Nothing, Nothing) -> Nothing
        (Nothing, Just etn) -> Just (e2:etn)
        (Just e2n, Nothing) -> Just (e2n++et)
        (Just e2n, Just etn) -> Just (e2n++etn)
    where
        nch = entrytree_map_maybe_ f (entrytree_children e2) (0:rrr)
        e2n = f e2 nch (Loc $ reverse rrr)
        etn = entrytree_map_maybe_ f et ((r+1):rr)
entrytree_map_maybe_ f (e2:et) rrr@(r:rr) =
    case (e2n, etn) of
        (Nothing, Nothing) -> Nothing
        (Nothing, Just etn) -> Just (e2:etn)
        (Just e2n, Nothing) -> Just (e2n++et)
        (Just e2n, Just etn) -> Just (e2n++etn)
    where
        nch = entrytree_map_maybe_ f (entrytree_children e2) (0:rrr)
        e2n = f e2 nch (Loc $ reverse rrr)
        etn = entrytree_map_maybe_ f et ((r+1):rr)