}
final ArrayList<String> entityNames = new ArrayList<String>();
entityNames.add(dataEntity.getName());
ContentLocation location = dataEntity.getParent();
while (location != null)
{
entityNames.add(location.getName());
location = location.getParent();
}
if (sourceDocument instanceof ContentLocation)
{
location = (ContentLocation) sourceDocument;
}
else
{
location = sourceDocument.getParent();
}
final ArrayList<String> contentNames = new ArrayList<String>();
while (location != null)
{
contentNames.add(location.getName());
location = location.getParent();
}
// now remove all path elements that are equal ..
while (contentNames.isEmpty() == false && entityNames.isEmpty() == false)
{