public function searchUserByLogin($username, $parentGroupId = null)
    {
        try {
            $user = $this->userService->loadUserByLogin($username);
        } catch (ApiExceptions\NotFoundException $e) {
            return null;
        }

        if ($user && $parentGroupId) {
            $userGroups = $this->userService->loadUserGroupsOfUser($user);

            foreach ($userGroups as $userGroup) {
                if ($userGroup->getVersionInfo()->getContentInfo()->id == $parentGroupId) {
                    return $user;
                }
            }
            // user not found in $parentGroupId
            return null;
        }

        return $user;
    }