from typing import Any


def get_columns(node: Any, df_cols: list) -> list:
    """Iterates over an xml element to retrieve columns

    Iterates over 'select' or 'drop' element of xml tree
    to create a list of columns that are defined under it

    Parameters
    ----------
    node: xml element
        an element of xml tree (select/drop)
    df_cols: list
        List of columns of the dataframe

    Returns
    ----------
    cols: list
        List of selected columns
    """
    cols = []
    for elem in node:
        attrib = elem.attrib
        col = attrib['name']

        if 'subcol' in attrib:
            col += "_" + attrib['subcol']

            if col not in df_cols:
                print(f"Invalid column: {col}")
                return []

            cols.append(col)

        elif col in df_cols:
            cols.append(col)

        else:
            col += "_"
            col_list = [x for x in df_cols if col in x]
            cols.extend(col_list)

    # remove duplicates
    cols = list(dict.fromkeys(cols))
    return cols