def parse_parent(docname):
    """ Given a docname path, pick apart and return name of parent """
    lineage = docname.split('/')
    lineage_count = len(lineage)
    if docname == 'index':
        parent = None
    elif lineage_count == 1:
        parent = 'index'
    elif lineage_count == 2 and lineage[-1] == 'index':
        parent = 'index'
    elif lineage_count == 2:
        parent = lineage[0] + '/index'
    elif lineage[-1] == 'index':
        parent = '/'.join(lineage[:-2]) + '/index'
    else:
        parent = '/'.join(lineage[:-1]) + '/index'
    return parent
