It would be quite "qucik and dirty", but based on terminus elevation and some threshold one can image an algorithm computing this...