lcast (StNode l r x lt rt) a b =
    if a <= l && r <= b
        then x
        else minimum $ (\(_, t) -> lcast t a b) `map` rs
    where
        midp = cmidp l r
        rs = (((a, b) `intersects`) . fst) `filter` [((l, midp - 1), lt), ((midp, r), rt)]
lcast (StNode l r x lt rt) a b =
    if a <= l && r <= b
        then x
        else minimum $ (\(_, t) -> lcast t a b) `map` rs
    where
        midp = cmidp l r
        rs = (((a, b) `intersects`) . fst) `filter` [((l, midp - 1), lt), ((midp, r), rt)]
lcast (StNode l r x lt rt) a b =
    if a <= l && r <= b
        then x
        else minimum $ (\(_, t) -> lcast t a b) `map` rs
    where
        midp = cmidp l r
        rs = (((a, b) `intersects`) . fst) `filter` [((l, midp - 1), lt), ((midp, r), rt)]