<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_pyfqn(cls, value, relative_to=0):
 """ Returns Python form of fully qualified name. Args: relative_to: If greater 0, the returned path is relative to the first n directories. """


        def collect_packages(element, packages):
            parent = element.eContainer()
            if parent:
                collect_packages(parent, packages)
            packages.append(element.name)

        packages = []
        collect_packages(value, packages)

        if relative_to < 0 or relative_to > len(packages):
            raise ValueError('relative_to not in range of number of packages')

        fqn = '.'.join(packages[relative_to:])

        if relative_to:
            fqn = '.' + fqn

        return cls.module_path_map.get(fqn, fqn)