Helper to get the last valid coordinate within a container.