'Get tree path as a list() starting with root element,
for objects implementing a tree-like structure via .parent'

def get_tree_path(self, skipself=False):

    if skipself:
        path = []
    else:
        path = [self]
    current = self
    while getattr(current, 'parent', None):
        parent = getattr(current, 'parent')
        if (parent in path):
            break
        else:
            path.insert(0, parent)
        current = parent
    return path
