def hierarchy_sanity_check(nodes):
    """ Checks for errors in the skeleton's hierarchy.
    
    :param nodes: Dictionary with skeleton hierarchy.
    :type nodes: dict
    :return: True if no error occurred.
    :rtype: bool
    """
    found_root = False
    for node, properties in nodes.items():
        parent = properties['parent']
        if not parent:
            if found_root:
                raise ValueError("ERROR: Hierarchy can't have more than 1 root!")
            else:
                found_root = True
        if node == parent:
            raise ValueError("ERROR: Joint {} cannot be parent of itself!".format(node))
        if parent in properties['children']:
            raise ValueError("Impossible cyclic relation detected for joints {} and {}!".format(node, parent))
        if parent and parent not in nodes.keys():
            raise ValueError("ERROR: Parent of joint {} cannot be found in the hierarchy definition!".format(node))
    if not found_root:  # Would probably be caught before.
        raise ValueError("ERROR: No root joint found in the hierarchy definition!")
        
    # No error occurred.
    return True