deviceTreeRemove :: Text -> DeviceTree -> DeviceTree
deviceTreeRemove path root = root { deviceNodeChildren = cs' }
   where
      cs = deviceNodeChildren root
      cs' = case bkPath path of
               (x,xs)
                  | Text.null x 
                    && Text.null xs -> error "deviceTreeRemove: empty path"
                  | Text.null xs    -> Map.delete x cs
                  | otherwise       -> Map.update (Just . deviceTreeRemove xs) x cs

-- insert a node in the tree
deviceTreeRemove :: Text -> DeviceTree -> DeviceTree
deviceTreeRemove path root = root { deviceNodeChildren = cs' }
   where
      cs = deviceNodeChildren root
      cs' = case bkPath path of
               (x,xs)
                  | Text.null x 
                    && Text.null xs -> error "deviceTreeRemove: empty path"
                  | Text.null xs    -> Map.delete x cs
                  | otherwise       -> Map.update (Just . deviceTreeRemove xs) x cs

-- insert a node in the tree
deviceTreeRemove path root = root { deviceNodeChildren = cs' }
   where
      cs = deviceNodeChildren root
      cs' = case bkPath path of
               (x,xs)
                  | Text.null x 
                    && Text.null xs -> error "deviceTreeRemove: empty path"
                  | Text.null xs    -> Map.delete x cs
                  | otherwise       -> Map.update (Just . deviceTreeRemove xs) x cs

-- insert a node in the tree