<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def make_needed(pattern, path_to_directory, wanted):
 """Make a method to check if an item matches the pattern, and is wanted If wanted is None just check the pattern """

    if wanted:
        def needed(name):
            return fnmatch(name, pattern) and wanted(
                os.path.join(path_to_directory, name))
        return needed
    else:
        return lambda name: fnmatch(name, pattern)