private function checkRoleHierarchyPermission($roleName, $permissionName, $role)
    {
        // Can current user manipulate role?
        if (is_string($role)) {
            $permissions = $this->app['config']->get("permissions/roles-hierarchy/$permissionName/$role", []);

            return in_array($roleName, $permissions);
        }

        // Can current user manipulate user?
        $user = $role;
        foreach ($user['roles'] as $role) {
            $permissions = $this->app['config']->get("permissions/roles-hierarchy/$permissionName/$role", []);
            if (in_array($roleName, $permissions)) {
                return true;
            }
        }

        return false;
    }