'Uses Floyd\'s cycle-detection algorithm to detect a cycle (aka Tortoise and Hare)
https://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare'

def _contains_cycle(self):

    if ((self.parent_directory is not None) and (self.parent_directory.uuid == self.uuid)):
        return True
    slow = self
    fast = self
    while True:
        slow = slow.parent_directory
        if (slow and (slow.uuid == self.uuid)):
            slow = self
        if (fast.parent_directory is not None):
            if (fast.parent_directory.uuid == self.uuid):
                fast = self.parent_directory.parent_directory
            else:
                fast = fast.parent_directory.parent_directory
        else:
            return False
        if ((slow is None) or (fast is None)):
            return False
        if (slow == fast):
            return True
