def _get_path_for(root, tlobject):
    """Creates and returns the path for the given TLObject at root."""
    out_dir = root / ('methods' if tlobject.is_function else 'constructors')
    if tlobject.namespace:
        out_dir /= tlobject.namespace

    return out_dir / _get_file_name(tlobject)