I've seen some code around to determine the table that occupies the top-most block (away from the office - I don't have it to hand).

I think I'd look at the size of the top-most table compared to the size of the free space when moving within the same TS. If the table is bigger than free space "lower down" the TS, then moving it will push up the high-water mark of the TS - this isn't what you want.