from typing import OrderedDict


def get_stepped_value(value, step, step_type='Down'):
    """Returns the rounded value, given an initial input value.

    Args:
        value(int): The input value
        step(int | OrderedDict):  The step value
        step_type(str):  Whether the value is incremented to the next step

    Raises:
        ValueError

    Returns:
        int

    """
    if isinstance(step, OrderedDict):
        attribute_step = step.copy()
        threshold_value, threshold_step = attribute_step.popitem(last=False)
        while value >= threshold_value:
            try:
                threshold_value, threshold_step = attribute_step.popitem(last=False)
            except KeyError:
                break
        step = threshold_step
    if not isinstance(step, int):
        raise KeyError("Unexpected argument for step.")

    if step_type in {'Up', 'Down'}:
        added_step = (step if value % step > 0 and step_type == 'Up' else 0)
    elif step_type == 'Round':
        added_step = (step if float(value % step) / step >= 0.5 else 0)
    else:
        raise TypeError

    return value // step * step + added_step