def update_aliases(df, new_aliases=None, inplace=False):
    """
    For each object:
        1. Add new aliases if any
        2. Make sure unique pipe-separated list with OBJECT first in list
    Args:
        df (pd.DataFrame): dataframe with an ALIASES column
        new_aliases (Series, array, list): aliases to append for each object.
            If Series, make sure indexes match the dataframe
        inplace (bool): If true, edit df directly, otherwise return a copy
    """
    if not inplace:
        df = df.copy()

    # Make sure all strings
    df.ALIASES = df.ALIASES.fillna('')

    # Add new aliases
    if new_aliases is not None:
        new_aliases = new_aliases.fillna('')
        df.ALIASES = df.ALIASES.str.cat(new_aliases, sep='|')

    # Make sure 2MASS and Gaia included
    aliases = df.ALIASES.copy()
    mask_gaia = df.GAIADR2ID.notnull()
    aliases[mask_gaia] = aliases[mask_gaia].str.cat(
            'Gaia DR2 ' + df.GAIADR2ID[mask_gaia]
            )
    mask_2mass = df['TWOMASSID'].notnull()
    aliases[mask_2mass] = aliases[mask_2mass].str.cat(
            '2MASS J' + df['TWOMASSID'][mask_2mass]
            )

    # Make sure object is not current list, and that list is unique
    objs = df.OBJECT.tolist()
    aliases = df.ALIASES.apply(  # Remove object name and empty strings
            lambda row: [val for val in row.split('|')
                         if val not in objs + ['']
                         ]
            )
    aliases = aliases.apply(set).str.join('|')  # Unique and join with pipe

    # Add object name as first alias
    al_mask = aliases.str.len() > 0
    df.loc[al_mask, 'ALIASES'] = df.OBJECT.str.cat(aliases, sep='|')
    df.loc[~al_mask, 'ALIASES'] = df.OBJECT.copy()

    return None if inplace else df