So, I have a list like following
potential_labels = ['foo', 'foo::bar', 'foo::bar::baz', "abc", "abc::cde::def", "bleh"]
The desired_output = ['foo::bar::baz', "abc::cde::def", "bleh"]
This is because.. for root "foo", 'foo::bar::baz' is the longest sequence for "abc", "abc::cde::def", and for "bleh" it "bleh"
Is there any python inbuilt function which does this.. I feel like there is almost something in itertools which does this but cant seem to figure this out.