Algorithms for DocumentModel

Change-Id: I9065951548a85190c991339f93cf57be2e1617da
Reviewed-by: Daniel Teske <daniel.teske@digia.com>