def portfolio_accounts(accapi, configs):
    """An account tree based on matching regex patterns."""
    portfolios = []
    for config in configs:
        pattern_type = config['pattern_type']
        func = globals()['by_' + pattern_type]
        portfolio = func(accapi, config)
        portfolios.append(portfolio)
    return portfolios
