def METHOD_NAME(self) -> dict[str, typing.Any]:
    """
    reads the directory that's currently pointed at by self.data.
    descends recursively for subdirectories.
    returns a ResourceDirectory object with both subdirs and leaves filled
    in.
    """
    directory = ResourceDirectory.read(self.data)
    result = {}
    # read directory entries
    entry_count = directory.named_entry_count + directory.id_entry_count
    for idx in range(entry_count):
        entry = ResourceDirectoryEntry.read(self.data)
        # check the entry name
        entry.name_is_str = bool(entry.name & (1 << 31))
        if entry.name_is_str and idx >= directory.named_entry_count:
            raise SyntaxError("expected an id entry, but got a str entry")
        if not entry.name_is_str and idx < directory.named_entry_count:
            raise SyntaxError("expected a str entry, but got an id entry")
        # read the entry name string, if needed
        if entry.name_is_str:
            data_pos = self.data.tell()
            self.data.seek(entry.name - (1 << 31))
            entry.name = StringLiteral.readall(self.data).value
            self.data.seek(data_pos)
        # read the struct pointed at by entry.data
        entry.is_subdir = bool(entry.data & (1 << 31))
        data_pos = self.data.tell()
        if entry.is_subdir:
            # recursively descend
            self.data.seek(entry.data - (1 << 31))
            result[entry.name] = self.METHOD_NAME()
        else:
            # read leaf metadata
            self.data.seek(entry.data)
            leaf = ResourceLeaf.read(self.data)
            leaf.data_ptr -= self.datava
            leaf.fileobj = self.data
            result[entry.name] = leaf
        self.data.seek(data_pos)
    return result