def handle_aliases_in_init_files(name, import_alias_mapping):
    """Returns either None or the handled alias.
    Used in add_module.
    """
    for key, val in import_alias_mapping.items():
        # e.g. Foo == Foo
        # e.g. Foo.Bar startswith Foo.
        if name == val or \
                name.startswith(val + '.'):

            # Replace val with key in name
            # e.g. StarbucksVisitor.Tea -> Eataly.Tea because
            #   "from .nested_folder import StarbucksVisitor as Eataly"
            return name.replace(val, key)
    return None
Returns either None or the handled alias.
    Used in add_module.