Removing non-unique prefixed lines from a list

Not quite sure how to explain what I need to do (or how to title the post!) so will try and show it!

Basically I have a list of 'modules' which takes the form seen below, where there can be a module name, module type and module version (a module may not have each of those and could in theory have more (subversion etc). Also version can be name or number). The list contains an entry for each name; name and type; and name, type version, so for example:

apache-ant
apache-ant/1.8.4
atlas
atlas/gcc
atlas/gcc/3.8.4
atlas/gcc/3.8.6
binutils
binutils/2.22
binutils/2.23
codeutils/
codeutils/testing
codeutils/working
codeutils/live/1.2

I'm only interested in the final unique entry for each module, so what I want to do is remove the non-unique branches of list, i.e. going from the above list to the list below:

apache-ant/1.8.4
atlas/gcc/3.8.4
atlas/gcc/3.8.6
binutils/2.22
binutils/2.23
codeutils/testing
codeutils/working
codeutils/live/1.2

I'm not even sure where to start with this, after disregarding rev, uniq etc, though no doubt I'm missing some simple solution!

Any help as always appreciated

Try:

awk '{print length" "$0}' file | sort -nrk1 | awk '{f=0;for (i in a) if (index (i,$2)!=0) f=1;if (!f) a[$2]=1}END{for (i in a) print i}' | sort

Brilliant, thank you!